Requests and Responses


In general, the OnlinePajak OpenAPI implements HTTP requests with JSON arguments in the payload body and JSON responses as well.

JSON Structure

Request Structure

In general, all requests will have the following structure:

 {
    "key1": "value1",
    "key2": "value2"
  }

Response Structure

In general, all responses that returns data will have the following structure:

{
  "success": {
    "code": "00",
    "message": "The resource has been successfully created."
  },
  "data": {
    "id": "5153414a-a8b9-4800-90fa-e154107ccff1",
    "key1": "value1",
    "key2": "value2"
  }
}

Error Structure

In general, all Error structures related to application will have either of the following structures:

  1. Single Error Json Response :

    An Error response containing just one error message

{
  "error": {
    "code": "90",
    "message": "Whoops! Something went wrong, please contact integration@online-pajak.com, if the issue persisted.",
    "errorId": "45e2cc35-3c3c-4962-8d05-524bf2d16195"     -- errorId is optional
  }
}
  1. Multiple Error Json Response :

    An error message may contain an array of error messages

{
  "errors": [{
    "code": "90",
    "message": "Whoops! Something went wrong, please contact integration@online-pajak.com, if the issue persisted."
  }, 
{
    "code": "90",
    "message": "Field 1 is Invalid"
  },
{
    "code": "90",
    "message": "Field 2 is invalid"
  }]
}

Some errors, that is related with our API Gateway will have a slightly different structure, e.g.:

  1. Missing Access Token:

    {
      "message": "Unauthorized"
    }
    
  2. Invalid Access Token:

    {
      "message": "Invalid signature"
    }
    

HTTP Status Codes

OnlinePajak uses the conventional HTTP response codes to indicate the success or failure of an API request, but also including an internal code that is present in the success.code or error.code JSON body. For HTTP Status Code, in general, codes in the 2xx range indicate a successful request, codes in the 4xx range indicate a failed request susceptible to client error or false implementation, and codes in the 5xx range indicate a failed request that is caused from OnlinePajak side.

HTTP Status Code Summary

HTTP Status Code Description
200 - OK Your request is accepted and everything is working as expected.
201 - Created Your create resource request is accepted and a new ID has been issued.
400 - Bad Request Your request is not accepted, often due **not** to a required parameter issue, but to a Business Logic issue, e.g. you cannot approved a Faktur Pajak that has already been approved.
401 - Unauthorized Your request does not include an Access Token or your Access Token is invalid.
403 - Forbidden Your request includes a valid Access Token, but you do not have sufficient access to the resource or you are accessing a feature that is not enabled for your integration.
404 - Not Found You requested an endpoint that is not a valid one or the resource you are looking for does not exist in our record.
412 - Precondition Failed Your request is not acceptedted, because of invalid parameter validation issue.
500 - Internal Server Error Your request is failed to be handled by OnlinePajak because of server issues.
503 - Service Unavailable Your request is failed to be handled by OnlinePajak because of service unavailability.