Create Expense Code


POST /v2/api/corporate/expenseCode

For corporates that wish to integrate internal trip approval flows with the Expense Code feature, the following process may be followed:

  • Expense Code to be made mandatory for all employees of the corporate.
  • No expense code created for any of the employees by default - By extension, these employees wouldn't be able to take rides marked as corporate unless they have a valid expense code.
  • Through internal approval flows, corporates pre-approve or reject rides for employees and internal Travel Request is created for the employee.
  • Through Ola Corporate APIs, the expense code is created for the respective employees - once an expense code is available for an employee, the employee may take rides.
  • Once an expense code expires please use the delete expense code API to remove expired codes from the system.

Request Parameters

Name Data Type Description Type Remark
expense_code string Expense Code Name Payload Mandatory
capping map

Capping

  • start_time (Date), format:"dd-MM-yyyy hh:mm:ss"
  • end_time (Date), should be greater than start_date and same format
  • ride_cap (Integer), Should be > 0
Payload Optional
scopes list of objects

Scopes

  • expense_code_creation_level (string), values are case sensitive and allowed - { CORPORATE/GROUP/EMPLOYEE }, Mandatory
  • expense_code_created_for (string), Mandatory for GROUP and EMPLOYEE
Payload Mandatory
  • Example Request

    POST

    https://devapi.olacabs.com/v2/api/corporate/expenseCode

    
        {
          "expense_code": "ExpenseCodeName",
          "scopes": [
            {
              "expense_code_creation_level": "EMPLOYEE",
              "expense_code_created_for": "sav@mailinator.com"
            },
            {
              "expense_code_creation_level": "GROUP",
              "expense_code_created_for": "Freshers"
            },
            {
              "expense_code_creation_level": "GROUP",
              "expense_code_created_for": "SanityGroup"
            },
            {
              "expense_code_creation_level": "CORPORATE",
              "expense_code_created_for": null
            }
          ],
          "capping": {
            "start_time": "12-01-2018 00:19:00",
            "end_time": "15-01-2018 12:10:00",
            "ride_cap": 10
          }
        }
    
        Headers: {
          X-CORPORATE-TOKEN: fd5d4d3726121212f12ff12f12f1f12f1f12fa
        }
    
    

    Example Response (Success)

    
        {
          "expense_code": "ExpenseCodeName",
          "expense_code_created": true,
          "successful_scopes": 3,
          "failed_scopes": 1,
          "expense_code_message": "Expense code successfully created",
          "expense_code_scope_error_dtos": [
            {
              "entity_type": "EMPLOYEE",
              "entity_created_as": "sav@mailinator.com",
              "entity_error": "Successfully Added",
              "successful": true
            },
            {
              "entity_type": "GROUP",
              "entity_created_as": "Freshers",
              "entity_error": "Corporate Group doesn't exist",
              "successful": false
            },
            {
              "entity_type": "GROUP",
              "entity_created_as": "SanityGroup",
              "entity_error": "Successfully Added",
              "successful": true
            },
            {
              "entity_type": "CORPORATE",
              "entity_created_as": "NA",
              "entity_error": "Successfully Added",
              "successful": true
            }
          ]
        }
    
    

    Example Responses (Failures)

    • Invalid expense_code_creation_level

        expense_code_creation_level should be one of the following: CORPORATE GROUP EMPLOYEE 
          {
            "code": 400,
            "message": "Unable to process JSON"
          }
      
    • Invalid expense code

        Expense code cannot be null
          {
            "errors": [
            "expense_code can not be null"
            ]
          }
      
    • Invalid expense_code_created_for

        expense_code_created_for should be null when expense_code_creation_level is CORPORATE expense_code_created_for should not be null when expense_code_creation_level is GROUP or EMPLOYEE 
          {
            "errors": [
              "Invalid expense_code_created_for : expense_code_created_for should be null for corporate,expense_code_created_for should not be null for group/employee"
            ]
          }
      
    • expense code already exists for entity

        Request:
          [
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "CORPORATE",
              "expense_code_created_for": null
            },
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "GROUP",
              "expense_code_created_for": "Manager Group"
            },
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "EMPLOYEE",
              "expense_code_created_for": "employee@corporate.com"
            }
          ]
      
        Response:
          {
            "created_count": 0,
            "error_count": 3,
            "error_messages": [
              {
                "expense_code_creation_level": "CORPORATE",
                "expense_code_created_for": null,
                "expense_code": "EXPENSECODE",
                "message": "Expense code EXPENSECODE already exists for CORPORATE"
              },
              {
                "expense_code_creation_level": "GROUP",
                "expense_code_created_for": "Manager Group",
                "expense_code": "EXPENSECODE",
                "message": "Expense code EXPENSECODE already exists for Manager Group"
              },
              {
                "expense_code_creation_level": "EMPLOYEE",
                "expense_code_created_for": "employee@corporate.com",
                "expense_code": "EXPENSECODE",
                "message": "Expense code EXPENSECODE already exists for employee@corporate.com"
              }
            ]
          }
      
      
    • expense code is too long

        Request:
          [
            {
              "expense_code": "THIS EXPENSE CODE IS TOO LONG LET'S HAVE A SMALLER EXPENSE CODE",
              "expense_code_creation_level": "CORPORATE",
              "expense_code_created_for": null
            }
          ]
      
        Response:
          {
            "created_count": 0,
            "error_count": 1,
            "error_messages": [
              {
                "expense_code_creation_level": "CORPORATE",
                "expense_code_created_for": null,
                "expense_code": "THIS EXPENSE CODE IS TOO LONG LET'S HAVE A SMALLER EXPENSE CODE",
                "message": "Expense code THIS EXPENSE CODE IS TOO LONG LET'S HAVE A SMALLER EXPENSE CODE should be less than 50 characters"
              }
            ]
          }
      
      
    • expense_code_created_for does not exists

        Request:
          [
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "GROUP",
              "expense_code_created_for": "Wrong Group"
            },
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "EMPLOYEE",
              "expense_code_created_for": "wrong.employee"
            }
          ]
      
        Response:
          {
            "created_count": 0,
            "error_count": 2,
            "error_messages": [
              {
                "expense_code_creation_level": "GROUP",
                "expense_code_created_for": "Wrong Group",
                "expense_code": "EXPENSECODE",
                "message": "Corporate Group not found with given name"
              },
              {
                "expense_code_creation_level": "EMPLOYEE",
                "expense_code_created_for": "wrong.employee",
                "expense_code": "EXPENSECODE",
                "message": "Corporate User not found with given email address"
              }
            ]
          }