Understanding the Documentation
This documentation helps you to understand what endpoints can be called to perform various actions within the API.
In general, the the V2 API is a CRUD based RESTful API. For the most part, each resource will have its own group of endpoints which follow the CRUD pattern of Create
, Read
, Update
and Delete
(with an additional one for searching or listing multiple records).
This page will help you understand how the documentation is structured.
Resource Schemas
Each group of endpoints can be found on the left side menu. At the start of each page of endpoints is a schema for how that resource is returned from the API. The schema provided is an example schema, and provides a table of definitions for each item in the schema.
Example Schema
Properties
- Name
id
- Required
- Type
- integer
- Description
Unique identifier for the record
- Name
foo
- Required
- Type
- string | null
- Description
An example field
- Name
dates
- Required
- Type
- object
- Description
- Name
created_at
- Required
- Type
- datetime
- Description
The date the record was created, represented in
YYYY-MM-DD HH:MM:SS
format
Example Resource
{
"id": 1,
"foo": "bar",
"dates": {
"created_at": "2024-01-01 00:00:00"
}
}
In the example above, we have the example schema represented in JSON to the right, and a definition table on the left.
The definition table will give you a description of each property of the schema. Each field in the definition table will provide 3 pieces of data:
- The field key
- The field type or types
- A description
The field key will always be highlighted in code
tags.
To the right of the field key is the field type, or types. Each field will have one or more types, such as int
, string
, null
, object
.
If the field type is an object, the description will always contain a child definition list which follows the same structure. Otherwise, the description will give you any additional information you may need to know about that particular field.
Endpoint Definitions
Endpoint definitions allow you to see exactly what URLs to call to perform various actions, what method should be used, definitions of any URI parameters, payload structures, responses, SDK and cURL example calls, errors returned etc.
When implementing an endpoint, the documentation should be used as a source of truth, and the implementation must match the documentation exactly.
Example Endpoint Definitions
Create Resource
An example endpoint definition that describes what this endpoint does, along with the request structure, errors and responses.
Payload
- Name
foo_a
- Required
- required
- Type
- string | null
- Description
An example property to provide in the request.
- Name
foo_b
- Required
- Type
- string
- Description
Another example property to provide in the request.
Error Codes
Status | Description |
---|---|
422 | The data provided in the payload was invalid. See errors for more details. |
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
private ApexV3SdkInterface $sdk;
$response = $this->sdk
->v2(new Machine())
->resources()
->create([
'foo_a' => 'Hello',
'foo_b' => 'World',
]);
Response
{
"data": {
"id": 1,
"foo_a": "bar",
"foo_b": "world",
"dates": {
"created_at": "2024-01-01 00:00:00"
}
}
}
In the example definition above, the page will always be split into 2 sections. The left side will give you information about the request, the right side will give you examples of how to make the request, and what to expect as a response.
In requests where a payload is expected, there will be a payload
title on the left hand side.
This section gives you details about what values to provide in the request and the structure of the request.
It follows the same structure as the resource definition table with an additional piece of information.
When a field is required, a red required
flag will be presented to the right of the field key.
If this flag is not displayed, the field is considered optional in the request.
When performing create
operations, if an optional field is not provided, a default value will be stored. The default value will usually be displayed within the description of the field.
When performing update
operations, if an optional field is not provided in the request, it will not be updated in the database.
For example, in the request definition above, foo_b
is not a required field. If the existing record has a value of foo_b: Space
and we provide foo_b: World
in the request, this value will be updated to World
.
If we don't provide foo_b
at all in the request, the value will remain as Space
in the database.
There may be occasions where a field accepts multiple different data types, such as int | null
. This means when provided in the request, the value must be either an integer
or null
.
So, using the example endpoint above to create a resource, the following requests are both acceptable:
This is an acceptable payload because both fields are provided, even though foo_b
is optional, and both values are valid data types according to the documentation.
{
"foo_a": "Hello",
"foo_b": "World"
}
This is an acceptable payload, because foo_a
is provided as its a required field, and its the correct datatype. foo_b
is not provided, but it is not a required field.
In this scenario, if this was a create
operation, foo_b
would be set to a default value. If this was an update
operation, the existing stored value foo_b
would not change.
{
"foo_a": "Hello"
}
However, these requests would fail:
This would fail because foo_a
is a required field which hasn't been provided in the request.
{
"foo_b": "World"
}
This would fail because while foo_b
has been provided, its data type is null
for a field which only accepts string
values when the key is provided.
{
"foo_a": "Hello"
"foo_b": null
}