ULID
All Nmbr entities have anid. These ids are based on a customized version of ULIDs. Nmbr ULIDs take the form of a standard ULID prefixed with a namespace reference.
For example, an employee may be emp_01JAV10D4QJ3500QANBTTBW9DW, and a company may be cmp_01JAV11013A9V4V0F30099BVGH.
Response Structure
Objects across the Nmbr API follow a consistent JSON structure, either a single Entity, a Pageable List, or a Non-Pageable List. Entities and Lists can be returned as the root response on an endpoint.Entities
Entity Responses will follow the structure:Pageable Lists
Pageable Lists contain up to 15 objects per-page and can be paged using the associatedlinks data. The object type will always have the value list .
Non-Pageable Lists
Non-Pageable Lists are returned for lists with no related endpoint to page through. In these cases the complete data set will be returned as alist with no paging information.
Related Resources
Entities will contain references to other objects - e.g an Employee will contain a Company reference. By default, these will be “stub” entities which will have nodata attribute. They may be an Entity, a Pageable List or a Non-Pageable List.
Expanding Resources
If you would like to retrieve thedata of a related resource inline, you may pass the expand array parameter to expand its contents.
Request:
data by passing the expand parameter in your request.
You can expand multiple layers down by defining dot (.) notation values to the expand array.
In the following example, the company entity is expanded to a full company resource, and its pageable-list of business_entities is expanded into a list of business_entity resources.
Request:
Using the expand array
Multiple objects can be expanded by passing multiple values to the expand parameter.
Some objects have properties which are arrays of data - if there is an expandable property in such an array, you must pass the dot-property of the array.property. For example, to expand the recurring_allowance in a allowance_line_item, you must pass the parameter expand[]=allowance.recurring_allowance.
The expand parameter can also accept a comma separated list of expandable attributes: expand=company,allowance.recurring_allowance.
Request
Maximum expansion depth
expand parameters using dot-properties for deep expanding may go up to 4 layers deep. For example, the following is a valid expand argument on a pay_stub: work_assignment.pay_rate.expense_accounting_code.business_entity. However, no property on the business_entity may be expanded.
Expanding optional properties
Some resources will have expandable properties that are not returned by default (i.e no “stub” entity will be returned by default). These optional properties will be documented as available, but must be requested in theexpand argument to be returned.
The expand parameter can be used to reduce the total number of requests required to use the Nmbr API, however it should be used only when required, as there may be a noticeable performance difference when querying for a single entity with no expand argument, vs a query with multiple expand arguments - especially when expanding attributes in a list.
Error Response Structure
When a client error (4xx) occurs, the Nmbr API returns a standardized error response.Bad Request (400)
A400 status code indicates that the request was invalid.
The response message explains why the request could not be processed.
Unauthorized (401)
A401 status code indicates that authentication has failed.
Forbidden (403)
A403 status code indicates that the client does not have permission to perform the requested action.
Not Found (404)
A404 status code indicates that the requested resource does not exist.
Unprocessable Entity (422)
A422 status code is returned when validation errors occur.
The response includes a summary message, an errors object detailing validation issues for each
field, and an error_details object giving each failure a code.
Handling a failure by code
errors is written for a person to read. The wording follows the language you request and can
change in any release, so branch your own code on error_details.
error_details is keyed by field the same way errors is, including the dotted path a batch or
bulk request reports (data.0.sin). Each entry describes one reason that field failed:
codenames the reason.required,maxanddate_formatname the rule the value broke.sin_formatandprovince_codename a check Nmbr applies to that kind of value.parameterscarries the values behind the reason, and is present only for a code that has them.maxreports its limit, so{ "code": "max", "parameters": ["50"] }reads as 50 characters.
pay_date_in_future
means the pay date has to be in the future. unchanged means the value has to match the one
already stored. Read the code as the requirement, and the matching message in errors for what
went wrong this time.
The same reason reports the same code wherever it is checked. A record that could not be found is
exists whether you referenced it by employee, by payroll or by remittance account, and the field
tells you which one Nmbr could not find.
Every field in errors has at least one entry in error_details, and a field that failed for
more than one reason gets one entry per reason. Read a field’s entries as a set rather than as an
ordered list.
Existing codes do not get renamed. New ones ship with new checks, so handle a code you do not
recognise as a plain rejection of that field. A code of unspecified means the failure has no
narrower code yet, and may report one in a later release.
Too Many Requests (429)
A429 status code indicates that you have gone over a rate limit. The request was not processed.
Retry-After header holding the number of seconds to wait before retrying,
along with the X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers. See
Rate Limits.
