Working with API
All the figures and data presented in the document are representational, you may get in touch with the CPX representative if you wish to access the API with data belonging to them or their corporation.
1. Request Header
For every request, you are required to share the authorization parameters in the request header i.e. Authorization: Bearer
2. Create Entities
All entities, within the system, use HTTP POST to create. Upon success, you will receive a “201 Created” response.
3. Update Entities
All entities, within the system, use HTTP POST to update. You will receive a "204 No content" response if the update is successful.
Note:
- Pass only those nodes that need an update in the update request.
- Pass the node value as "null" to delete any non-mandatory information.
4. Retrieve Entities by Id
All entities, within the system, use HTTP GET to retrieve data. You can retrieve an entity’s details using the CPX assigned system id.
Note:
- The APIs response contains all attributes of the entity.
- Any non-mandatory attributes having null values, will not be retrieved
- The response will return certain system assigned fields like creator, created, modified, modifier for each entity.
5. List Entities
All entities, within the system, use HTTP GET to list the entity data.
Following is the common structure shared by the all list API methods:
- Use HTTP GET for listing: HTTP GET method for listing APIs is supported by CPX to ensure the secure transmission of your sensitive data, such as, customer’s PII, account information, etc., to us.
- Filters: Multiple filters are supported by each entity list API to facilitate filtering the data on supported attributes. The response displays entity records that meet the defined filter criteria in the request.
- Sorting: Sorting of the data is supported by each entity. If no offset and sorting criteria are passed in the request, by default, the data will be sorted in a descending order of the lastUpdatedOn node.
- Response: You will receive a list of all objects meeting the requested filtration criteria along with some additional nodes, such as, total count, record count. The response for each entity will only present specific attributes that provide essential information for the entity, instead of all.
6. Errors & Warnings
CPX uses conventional HTTP response codes to indicate the success or failure of an API request.
- Codes in the 2xx range indicate success.
- Codes in the 4xx range indicate an error i.e. failed given the information provided (e.g., a required attribute was omitted).
- Codes in the 5xx range indicate an error with CPX’s servers.
Table 2: Supported HTTP errors
Code | Description |
---|---|
200 - OK | The request completed successfully as expected. (Used for gets) |
201 - Created | The requested resource has been created successfully. User can use the URL provided in the response header to fetch the complete details. |
204 - No Content | The Passport server successfully processed the request and is not returning any content. This is expected for all updates, deletion requests on the resources. |
5xx | Something went wrong on the CPX end and has to be investigated. Such errors are rare. |
6.1 API Error Codes and Messages
The CPX API error codes categorization is as follows: (refer table 3)
Table 3: Error Code Categories in API’S
Error Code | Condition |
---|---|
400 | |
401 | Unauthorized access |
403 | Forbidden Access |
404 | Not found |
Updated 3 days ago