Create a record

Add a record to an object by sending its values, keyed by field key.

POST/objects/{objectSlug}/records

The body has one property, values, keyed by field key. See Field values.

cURL
curl --fail-with-body "$JEMERO_URL/objects/people/records" \
  -H "Authorization: Bearer $JEMERO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "values": {
      "name": "Ada Lovelace",
      "email": "[email protected]",
      "jobTitle": "Analyst"
    }
  }'
Node.js
const response = await fetch(`${process.env.JEMERO_URL}/objects/people/records`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.JEMERO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    values: { name: 'Ada Lovelace', email: '[email protected]', jobTitle: 'Analyst' },
  }),
});
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
const { record } = await response.json();
console.log(record.id);
Python
import os
import requests

response = requests.post(
    f"{os.environ['JEMERO_URL']}/objects/people/records",
    headers={"Authorization": f"Bearer {os.environ['JEMERO_API_KEY']}"},
    json={
        "values": {
            "name": "Ada Lovelace",
            "email": "[email protected]",
            "jobTitle": "Analyst",
        }
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["record"]["id"])

The answer is 201 Created with { "record": … }, in the same shape as Get a record.

Errors#

StatusCause
400A value is invalid, a field is unknown or read-only, a required field is missing, or a linked record doesn't exist.
403Your role can't add records to this object, or can't set one of the fields.
404 Object not foundNo object with that slug.
409Another record already has the value of a unique field.
Response 400
{
  "error": "Validation Error",
  "issues": [
    { "path": "nickname", "message": "Unknown field" },
    { "path": "email", "message": "Enter a valid email" }
  ],
  "status": 400
}
Response 409
{
  "error": "Another record already has this email",
  "issues": [{ "path": "email", "message": "Another record already has this email" }],
  "status": 409
}