REST API¶
Each object type has its own REST API, such as /products or /orders, at the base URL https://apis.objectsgrid.com. The REST APIs also manage what GraphQL doesn't: accounts, the ABAC policy, access logs and enums.
Requests¶
Every request sends two headers:
- Request and response bodies are JSON: send
Content-Type: application/json. - Optionally, send
X-ObjectsGrid-SessionIDwith your app's session id. It is recorded with the request and returned in the response, so you can follow a user's session through your logs and ours. - Every response carries
X-ObjectsGrid-CorrelationID, the request's id, the same as its trace id inX-ObjectsGrid-Trace-Id. Quote it when you contact support.
Each API is described by an OpenAPI 3.1 contract, listed in the contract index. Load a contract into your favorite tool, such as Postman or an OpenAPI client generator, to get every operation, parameter and schema.
Operations¶
Most object types offer the same operations. For products:
| Operation | Request | Success |
|---|---|---|
| Create | POST /products |
201 with the object |
| Create up to 100 at once | POST /products/batch |
201 with the objects |
| List and search | GET /products |
200 with a list |
| Retrieve | GET /products/{id} |
200 with the object |
| Replace | PUT /products/{id} |
200 with the object |
| Update some fields | PATCH /products/{id} |
200 with the object |
| Delete | DELETE /products/{id} |
200 |
Some types offer fewer: log events can't be changed or deleted, and access logs can only be listed. Each page of the object reference lists the operations of its type.
Create¶
curl -i -X POST https://apis.objectsgrid.com/products \
-H 'Content-Type: application/json' \
-H 'X-ObjectsGrid-AccessPoint: EU' \
-H "Authorization: Bearer $TOKEN" \
-d '{"sku": "TRS-42", "name": [{"at_language": "en", "at_value": "Trail Running Shoe"}]}'
ObjectsGrid assigns the id, url and meta, validates the object against its schema and answers 201 with the stored object. The Location header holds its path and the ETag header its version. An object that isn't valid is refused with 400, and the error's reasons name the fields in error.
Enums are the one exception to assigned ids: you choose an Enum's id.
Retrieve¶
curl https://apis.objectsgrid.com/products/<id> \
-H 'X-ObjectsGrid-AccessPoint: EU' \
-H "Authorization: Bearer $TOKEN"
Add ?lang=de to get localized fields in one language: each keeps only its values in that language, an exact tag (de-AT) before a primary language (de). A field with no value in that language is returned whole.
Send Accept: application/ld+json to get the object as a Schema.org JSON-LD document for your web pages, with the objects it references and your own addresses: see JSON-LD for your pages.
Poll without downloading¶
Send the ETag you hold in If-None-Match: while the object is still at that version, the answer is
304 Not Modified, with no body, and isn't billed. Apps poll their
configuration and feature flags this way.
Earlier versions¶
Every write keeps the previous version. Add ?version=<objectVersion> to read one of them, with its meta.objectVersion and ETag:
curl "https://apis.objectsgrid.com/products/<id>?version=1763025002419837" \
-H 'X-ObjectsGrid-AccessPoint: EU' \
-H "Authorization: Bearer $TOKEN"
Earlier versions stay readable after the object is deleted. An earlier version carries the object's current tags, so your access control decides on today's tags. A version the object never had is 404.
Replace and update¶
PUTreplaces the object with the body you send. Fields you leave out are removed, with two exceptions:tagsand fields hidden from you by the ABAC policy are kept.PATCHchanges only what you send, following JSON Merge Patch (RFC 7396): a field you send replaces the stored value, a field set tonullis removed, and fields you leave out are unchanged. Send it asContent-Type: application/json.
curl -X PATCH https://apis.objectsgrid.com/products/<id> \
-H 'Content-Type: application/json' \
-H 'X-ObjectsGrid-AccessPoint: EU' \
-H "Authorization: Bearer $TOKEN" \
-d '{"color": "Green", "gtin13": null}'
id and meta can't be changed.
Delete¶
curl -X DELETE https://apis.objectsgrid.com/products/<id> \
-H 'X-ObjectsGrid-AccessPoint: EU' \
-H "Authorization: Bearer $TOKEN"
A deleted object is no longer returned by retrieve or list. Delete only what your users asked to delete.
Optimistic concurrency¶
Every object has a version, meta.objectVersion, returned as the ETag header. To make sure you don't overwrite a change someone made since you read the object, send the ETag back in If-Match with PUT, PATCH or DELETE:
curl -X PATCH https://apis.objectsgrid.com/products/<id> \
-H 'Content-Type: application/json' \
-H 'X-ObjectsGrid-AccessPoint: EU' \
-H "Authorization: Bearer $TOKEN" \
-H 'If-Match: "1763025002419837"' \
-d '{"color": "Green"}'
If the object changed since, the answer is 412 Precondition Failed and nothing is written: read it again, reapply your change and retry.
Without If-Match, ObjectsGrid still makes sure each write applies to the version your access was checked against. If the object changes in between, it checks again; 409 Conflict means the object kept changing, and you can retry.
List and search¶
GET /<type> answers a page of objects, {"items": [...], "pageInfo": {"endCursor": ..., "hasNextPage": ...}},
chosen with a where, ordered with an orderBy, and paged with first and after:
curl -G https://apis.objectsgrid.com/products \
-H 'X-ObjectsGrid-AccessPoint: EU' \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode 'where={"sku": "TRS-42"}' \
--data-urlencode 'orderBy={"meta": {"createdAt": "desc"}}' \
-d first=20
| Parameter | Meaning |
|---|---|
where |
The objects to list, as JSON: conditions on any field, combined with AND, OR and NOT. Without it, every object is listed. |
orderBy |
The order, as JSON: {"<field>": "asc"} or "desc", or a list of up to 3. |
first |
Number of objects, from 1 to 100; 20 by default. |
after |
The previous page's pageInfo.endCursor, for the next page. |
count |
true adds totalCount, how many objects the where matches. |
groupBy |
Groups instead of objects, with counts and aggregates. |
lang |
A BCP 47 language tag, as on retrieve. |
Lists has every condition, counting and grouping, and what your ABAC policy allows. The query
parameter, an Elasticsearch Query DSL request, was removed: use where and orderBy.
Batch create¶
POST /<type>/batch creates up to 100 objects of one type in one request:
curl -X POST https://apis.objectsgrid.com/products/batch \
-H 'Content-Type: application/json' \
-H 'X-ObjectsGrid-AccessPoint: EU' \
-H "Authorization: Bearer $TOKEN" \
-d '{"items": [
{"sku": "TRS-41", "name": [{"at_language": "en", "at_value": "Trail Running Shoe 41"}]},
{"sku": "TRS-42", "name": [{"at_language": "en", "at_value": "Trail Running Shoe 42"}]}
]}'
- All or nothing. Every object is validated and authorized first. If any one isn't valid or allowed, nothing is created and the error's
reasonsname it by position, such as/items/1/name. - The
201response holds{"items": [...]}, in the order of the request: each item has itsstatus,etagandobject. - Rarely, some objects can't be stored after the batch was accepted. The response is then
207, each item with its ownstatus, and anerrorfor the failed ones; the others stay created. - Each object created counts as one request against your monthly spending cap.
Log events have their own batch request; see Frontend logging.
References between objects¶
A field that points to another object is a Reference: send
"brand": {"at_id": "https://apis.objectsgrid.com/brands/<id>"}, and it is stored and returned as
{"at_id": ..., "id": "<id>", "at_type": "Brand"}. An object of a type the field may not point to, or a URL of
ObjectsGrid that names no object type, is refused with 400, naming the field; a URL outside ObjectsGrid is kept as
sent. The referenced object need not exist. See The data model.
REST returns references as they are stored. To read a referenced object, GET its at_id; to read several at once,
list their type with {"id": {"in": [...]}}, or use GraphQL, which reads them in the
same request.
Some references name one version of their target: an Order's customer is stored with
at_id <url>?version=<n>, the version that was newest when the Order was written. Send the plain URL, and the
referenced object must exist. Sending back the stored value keeps it, and the plain URL again pins the newest version.
Computed fields, such as a Product's review, are never sent: a write that holds one is refused with 400, naming
the field it is computed from.
Errors¶
Errors answer with an ErrorResponse:
{
"message": "The object is not valid",
"reasons": ["/sku: required"],
"httpStatusCode": 400,
"httpStatusText": "Bad Request",
"timestamp": 1763025002,
"correlationId": "4bf92f3577b34da6a3ce929d0e0e4736"
}
See Errors and troubleshooting for the status codes and what to do about each.