cardinal

REST API

Read and write Records, call RPC functions and upload files over HTTP.

Every endpoint lives on the site's own host, such as https://erp.acme.com/api/.... Bodies are JSON. Success is {"data": ...}. Every failure is {"error": {"type", "message", "fields"}}.

Authenticate

A user with write on a User's API key field generates a key pair:

curl -X POST https://erp.acme.com/api/auth/keys \
  -H 'Content-Type: application/json' -b cookies.txt -H "x-cardinal-csrf: $CSRF" \
  -d '{"user": "integration@acme.com"}'
# {"api_key": "3f9a1c2b7d8e4f60", "api_secret": "..."}

The secret is shown once. Send the pair on every request:

curl https://erp.acme.com/api/rec/Customer -H "Authorization: token $KEY:$SECRET"

Bearer KEY:SECRET and Basic auth over the same pair work too. Requests with a key need no CSRF token.

Records

:rectype is the RecType name, URL-encoded (Sales%20Invoice), or its desk slug (sales-invoice).

Method and pathDoes
GET /api/rec/:rectypeList. 20 rows unless limit is set
GET /api/rec/:rectype/countCount. cap=N stops at N
GET /api/rec/:rectype/newDefaults for a new Record
POST /api/rec/:rectypeInsert
GET /api/rec/:rectype/:nameRead, with recinfo (your rights on it)
PUT /api/rec/:rectype/:nameSave. The body must carry the modified you read
DELETE /api/rec/:rectype/:nameDelete
POST .../:name/submit, /cancel, /discard, /amendDocstatus actions
POST .../:name/rename{"new_name": "...", "merge": false}
GET .../:name/copyThe Record a Duplicate starts from
GET .../:name/timelineVersions, comments and communications, newest first
GET .../:name/recinfoYour rights and field levels, plus a page of Versions, Comments and Files (limit up to 500)
GET .../:name/connectionsThe Connections panel: linked RecTypes with the count of linked Records you may read
GET /api/meta/:rectypeThe RecType's compiled metadata. Needs a signed-in user

A single's Record is /api/rec/:rectype/:rectype, such as /api/rec/System%20Settings/System%20Settings. A PUT or submit without the modified you read is a 409.

List parameters are JSON in the query string: fields, filters, or_filters, limit, offset and distinct. order_by and group_by are text. A JSON null is the same as leaving the key out.

In fieldsMeans
*Every column you may read
items.item_codeA column of the items Table field's rows
count(*), sum(qty), avg(rate), min(f), max(f)Aggregates. With group_by, need the report right
month(posting_date), quarter(...), year(...), day(...)Date buckets for group_by

purpose=export marks a page of a CSV export. It needs the export right and reads within the first 10,000 rows. Naming a column you cannot read is a 403.

A write whose controllers raised warnings answers them as warnings: [...] beside data.

curl -G https://erp.acme.com/api/rec/Sales%20Invoice \
  -H "Authorization: token $KEY:$SECRET" \
  --data-urlencode 'fields=["name","customer","grand_total"]' \
  --data-urlencode 'filters=[["status","=","Overdue"],["grand_total",">","1000"]]' \
  --data-urlencode 'order_by=posting_date desc' \
  --data-urlencode 'limit=50'

Money and other decimals travel as strings ("1250.00"). A JSON number for a Currency field is refused. Datetimes are RFC 3339 in UTC, ending in Z.

RPC

Apps expose functions at /api/rpc/<app>.<module>.<function>, POST by default. Only functions the app marks @rpc answer, and each declares who may call it.

curl -X POST https://erp.acme.com/api/rpc/core.search.link \
  -H "Authorization: token $KEY:$SECRET" -H 'Content-Type: application/json' \
  -d '{"rectype": "Customer", "txt": "acme"}'
# {"data": [{"value": "CUST-0001", "label": "Acme Ltd", "description": ""}]}

Core's own functions are listed in RPC functions. A GET passes arguments in the query string. A multipart POST works only for core.web_form.accept.

Files

POST /api/file takes multipart form data: a file part plus is_private ("0" makes a public File), attached_to_rectype, attached_to_name and attached_to_field. A file over the site's max_file_size is a 413 and leaves nothing behind.

GET /api/file/:name redirects to a download URL that lives 300 seconds. ?download=1 makes the browser save the file.

Response headers

Every /api response of a site, except an immutable one, carries x-cardinal-meta and x-cardinal-perm, the site's metadata and permission versions, and x-request-id. The desk compares the version headers with its cache to know when its metadata is stale. API responses also send frame-ancestors 'none' and nosniff.

Errors

TypeStatusWhen
Validation422A value was refused. fields lists each as {path, code, message}
BadRequest400Malformed query or body
Authentication401Not signed in, or a failed login
Permission403You lack the right
CSRF403A session request without its token
NotFound404Unknown Record, RecType, function or host
TimestampMismatch409The Record changed since you read it
LinkExists409Other Records link to it. links lists them
DuplicateEntry409The name is taken
PayloadTooLarge413Body over 8 MB, or a file over the limit
RateLimited429Too many attempts. See Retry-After
Unavailable503The site is not active
Internal500A server error. Quote trace_id when you report it

On this page