Data API: Overview and setup
The Data API lets another system (an ERP, an e-commerce site, a script) read and change the records of your Xpoda forms over HTTPS, as JSON. Every request is made with an API key that belongs to an API user, and the API user's rights decide what the key may do, exactly as they would for a person using the form.
The Data API is the opposite of API Collections in Studio. API Collections call other systems from Xpoda; the Data API lets other systems call Xpoda.
What you can do
- List the forms a key may use, and get each form's field definitions (JSON Schema) and an OpenAPI 3.1 document for code generators.
- List records with filters, sorting and paging; read one record.
- Create, change and delete records. Writes go through the form's own save, so Record Control rules, after-save actions (integration, e-mail) and the "changed by another user" check work as they do on the form screen.
- Read and write grid lines together with their record, in one request.
Requirements
- Xpoda v5. The Data API screen appears in Studio only for v5 customers.
- The Xpoda Service must be reachable over HTTPS from the calling system.
- On-premises installations: the feature is off until it is switched on in the Service settings (see Data API: Administration and settings). Xpoda Cloud has it on.
How access is decided
A request succeeds only if all of these allow it:
| Check | Where you set it |
|---|---|
| The form is enabled for the Data API and has an API name | Studio, Data API, Forms tab |
| The key has the permission (Read, Create, Update, Delete) for that form | Studio, Data API, Keys tab, Permissions |
| The form is in the API user's menu | Client, Users, the API user's menu |
| The API user's form and field authorities allow it | Studio, form authorities (as for any user) |
| The key is active, not expired, and called from an allowed IP address | Studio, Data API, Keys tab |
Fields the API user cannot see are not returned and cannot be filtered on; fields it cannot change are read-only in the API.
Setting it up
Open Studio, choose the application and module, and open Data API from the menu.
1. Enable forms
On the Forms tab, tick Enabled for each form you want to offer and give it an API name: lowercase letters, digits and hyphens, for example stock-items. The API name is what appears in the URL, so callers are not affected if the form is renamed later. Click Save on the row.
2. Create an API user
On the API users tab, click New API user and enter a user name (for example erp-integration) and a full name.
- An API user is a Client user of a special type: it cannot sign in to Xpoda, it can only be used through API keys.
- It counts as a licence seat, like any other user.
- Use one API user per calling system, so you can see and limit each one separately.
Then, in Client, Users, give the API user:
- a menu containing the forms it should reach, and
- authorities, like any other user. A missing menu entry gives
403 form_not_in_menu.
3. Create a key
On the Keys tab, click New key:
| Field | Meaning |
|---|---|
| Name | What the key is for, e.g. ERP sync. |
| API user | The user whose rights the key carries. |
| Expires | Optional. After this date the key is refused with key_expired. |
| Requests per minute | Optional. Leave empty for the installation default (600). |
| Allowed IP addresses | Optional. Addresses or ranges, e.g. 203.0.113.7, 10.0.0.0/8. Empty means any address. |
The key is shown only once, right after it is created. Copy it into the calling system's secret store. Xpoda keeps only a fingerprint of it, so a lost key cannot be shown again: create a new one and revoke the old one.
4. Give the key permissions
In the key's row, click Permissions and tick Read, Create, Update and Delete per form. A permission works only if the API user may also do the same thing on the form.
5. Hand over to the developers
The Developer guide tab shows the base URL of your installation and ready-to-run examples (cURL, C#, JavaScript) for the form you select. Send it to the people building the integration together with the key, or point them to Data API: Reading records and Data API: Writing records.
Managing keys
- Usage (in the key's row) shows the key's recent requests: time, request, status, duration, IP address and error code.
- Revoke stops the key at once. Revoking cannot be undone.
- Rotate keys by creating a new key, switching the calling system to it, then revoking the old one.
Related articles
- Data API: Authentication, limits and errors
- Data API: Reading records
- Data API: Writing records
- Data API: Grid lines and grid forms
- Data API: Administration and settings