JSON API lets partner applications attach extra data to the records stored in Erply—"extend" the records with custom data.
In Erply's data model, each record has one additional JSON field. The tables in the database have the following layout:
id | ...Other fields... | jdoc |
---|---|---|
42 | ... | {"shipping": {"shippingStatus": "EN_ROUTE", "arrivalDate": "2020-07-14"}, "packing": {"packingStatus": "READY", "packedByEmployeeId": 28} } |
... | ... | ... |
This JSON field:
Thus, storing extended data in JSON is best suited for common applications that will be used by many customers. Fields that we will add to the schema should generally benefit many customers and their meaning should be well-understood, allowing applications to interoperate on the data if needed.
For building custom integrations, you may prefer to use attributes. Attributes can be defined ad-hoc and do not require a schema.
Use cases supported:
Use cases we intend to support soon:
packing.packingStatus
equal to "PENDING"
)At the moment, this functionality stands a bit separate from the rest of Erply APIs. However, where needed, we intend to provide a better integration between the "extended" data and "standard" data, such as allowing lookup by a JSON field in the "standard" API calls, or allowing to use the JSON data on Actual Reports customized printouts.
To request a field to be added to the JSON schema, please get in touch with Erply customer support, who will forward the request to backend development team.
This use case deserves a separate walkthrough. Previously, it was not possible to "extend" sales document rows with extra information at all.
First step: Retrieve the "stable IDs" of the sales document rows. Please note that the "regular" IDs of sales document rows change every time the document is edited. For integration purposes, we thus assign special "stable" IDs to these rows. These are returned by not only getSalesDocuments, but also saveSalesDocument.
Sample saveSalesDocument output:
{
"status": {
"request": "saveSalesDocument",
"responseStatus": "ok",
...
},
"records": [
{
"invoiceID": 446,
"invoiceNo": "100012",
...
"rows": [
{
"rowID": 1351,
"stableRowID": 1348, <--- This is the value to use for JSON API
"productID": 38,
"serviceID": 0,
"amount": "1"
}
]
}
]
}
Second step: To attach extra data to that invoice row, make a call to JSON API:
PUT /v1/json_object/inv_rows/1348
("table_name" is "inv_rows".)
Request body:
{
"json_object": {"MyApp":{"deliveryDate":"2020-08-01"}}
}
For this call to work, the key "MyApp" (and subkey "deliveryDate") must be added to the global schema of sales document rows, by Erply.
This is a REST API following Erply's new microservice standards. Key points:
"clientCode"
and "sessionKey"
.)