API (company key)
One API key for all of your company's Smart Forms, for your developers.
Your company has one API key for its Smart Forms. With it, your developers can send answers to any of the company's forms. They do not need a separate key for each form.
Make the key
Only the company's Owner or Admin can make or see the key.
- Open any Smart Form, go to Sources, and find the API card.
- Press Make company key. The key is shown — copy it and keep it safe.
- Later, Show key shows it again, and New key makes a new one. The old key stops working at once, in every system that uses it.
The API card shows how many times the key has been used, and when it was last used.
Send an answer
Send a POST request to the one address, naming the form:
https:///api/method/hros.hros.api.smart_form_sources.submit_api?form=<form id="">
The form id is shown in the API guide on the form's Sources tab (it starts with FRMT-).
The key
Send it in one of these ways:
| Way | Example |
|---|---|
| Header (best) | X-Sara-Key: |
| Bearer header | Authorization: Bearer |
| On the address | …submit_api?form=&api_key= |
The body
Use the form's own field names (the API guide on the Sources tab lists them). They become answers straight away, with no matching step. For example:
curl -X POST 'https:///api/method/hros.hros.api.smart_form_sources.submit_api?form=FRMT-000123' \
-H 'Content-Type: application/json' \
-H 'X-Sara-Key: ' \
-d '{"full_name": "Aisyah", "email": "aisyah@example.com", "department": "Finance"}'
If you send other names, the first delivery is kept as test data. Match it once on the form's Sources tab under API, and from then on those names work too.
The body is read the same way as a webhook's — JSON or form data, nested keys with dots, up to 256 KB. See Webhook for how each question type is read.
Python
import requests
r = requests.post(
"https:///api/method/hros.hros.api.smart_form_sources.submit_api",
params={"form": "FRMT-000123"},
headers={"X-Sara-Key": ""},
json={"full_name": "Aisyah", "email": "aisyah@example.com"},
timeout=30,
)
print(r.status_code, r.json())
JavaScript
const r = await fetch(
'https:///api/method/hros.hros.api.smart_form_sources.submit_api?form=FRMT-000123',
{
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-Sara-Key': '' },
body: JSON.stringify({ full_name: 'Aisyah', email: 'aisyah@example.com' }),
},
);
console.log(r.status, await r.json());
Send from your server, never from a web page or mobile app, where the key could be read.
Replies
| Code | Message | Meaning |
|---|---|---|
202 | Received. | Taken; the answer is made within a few seconds |
200 | Test data received. | None of the names were the form's; kept to match |
401 | Unauthorized. | Wrong or missing key, a switched-off key, an unknown form, or a form of another company |
403 | This source is switched off. | The form's API source is switched off in Sources |
413 | Body too large. | Over 256 KB |
429 | Too many requests. | More than 120 deliveries a minute to one form |
Every delivery — refused ones too — is in the form's delivery list on the Sources tab.
The same person again
The form's API source on the Sources tab holds its settings: how the same person is spotted, and whether a repeat is added as a new answer or skipped. It is made the first time you send to the form with the company key.
Each form's own key
A form can also have its own API source, with its own address and secret, like a webhook. Those keep working. For new work, use the company key.
</form>