Push API


The Push API is the simplest way to send ecommerce data to Ometria. To use the Push API you send an HTTP POST request to the push endpoint containing a JSON formatted array of objects. Each object represents a record of type "order", "product" or "contact". Each record is identified by a unique ID. Records will be added if no record exists with that ID, otherwise the information in the object will be merged in with the fields in the current record and saved.


Note, this API is designed to upload multiple records at once. You must ensure that you send a JSON formatted array of objects, even if you are only sending one record. A maximum of 100 records can be sent per call.

For example, the following JSON payload represents a single contact record being pushed to Ometria:

[{
    "@type": "contact",
    "id": "456",
    "email": "example@example.com"
}]


Updating existing records


To update an existing record, you can send a partial record and only the supplied fields will be merged into the existing record. For example, the following payload sets an existing order as "cancelled" and removes its revenue from Ometria's reporting:

[{
    "@type":"order",
    "id":"123551",
    "status":"cancelled",
    "is_valid":false
}]


The above order data could be submitted to Ometria via CURL using this command:

curl -X POST -H 'X-Ometria-Auth: YOUR_ACCESS_TOKEN' -H "Content-Type: application/json" -d '[{"@type":"order","id":"123551","status":"cancelled","is_valid":false}]' 'https://api.ometria.com/v2/push'


API responses


A successful response from the API looks like this:

{
    "status":"OK",
    "request_id":"e8d96762-7ee7-4c44-8ad4-48483712437f",
    "accepted":1,
    "rejected":0<span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span>
}


Requests are processed asynchronously so the "OK" result does not mean that the records passed validation and were successfully inserted. It only means that the request was correctly received and authenticated by the API system. You can use the returned "request_id" to look at request status.


Handling errors

You can retrieve the 100 latest push record errors using the /push/_errors call:

curl -i -H 'X-Ometria-Auth: YOUR_ACCESS_TOKEN'  https://api.ometria.com/v2/push/_errors