Records

List, filter, sort, page, create and update records of any object — the endpoints are the same for every object of your tenant.

Discover your objects#

Objects and fields differ per tenant. Start with the metadata:

curl https://jakun.dk/api/v1/meta/objects/lead -H "Authorization: Bearer $JAKUN_TOKEN"
r = httpx.get(f"{URL}/api/v1/meta/objects/lead", headers=H).json()
for f in r["data"]["fields"]:
    print(f["name"], f["type"], f.get("required"))
print(r["permissions"])  # what this key may do with the object

List, filter and sort#

GET /api/v1/{object} returns up to limit (default 50, max 200) records, newest first, and next_cursor while has_more is true.

curl -G https://jakun.dk/api/v1/lead \
  -H "Authorization: Bearer $JAKUN_TOKEN" \
  --data-urlencode 'filters=["and",["stage","in",["new","contacted"]],["created_at",">","$now-7d"]]' \
  --data-urlencode 'order=stage:asc,created_at:desc' \
  --data-urlencode 'limit=100'
import json

def all_leads():
    cursor = None
    while True:
        r = httpx.get(f"{URL}/api/v1/lead", headers=H, params={
            "filters": json.dumps(["stage", "=", "new"]), "limit": 200,
            **({"cursor": cursor} if cursor else {})}).json()
        yield from r["data"]
        if not r["has_more"]:
            return
        cursor = r["next_cursor"]
const q = new URLSearchParams({
  filters: JSON.stringify(["and", ["stage", "=", "new"], ["title", "ilike", "bad"]]),
  limit: "100" });
const page = await (await fetch(`${URL}/api/v1/lead?${q}`, { headers: H })).json();

Filter language#

A filter is a JSON domain: [field, operator, value], combined with ["and", …] / ["or", …]. The same syntax is used in views, permissions, automations and reports.

Operators= != > >= < <= like ilike in not in is null is not null contains between
Values$me — the caller; $now, $now-5d — relative time
containsMulti-select and tags: has every given value (["channels","contains",["call","sms"]]). Text, e-mails, phones, links: case-insensitive substring. Other types answer 422.
Compositevalue.amount, value.currency, address.city

Create and update#

curl -X POST https://jakun.dk/api/v1/lead -H "Authorization: Bearer $JAKUN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "Nyt badeværelse 8 m²", "stage": "new", "source": "website"}'

curl -X PATCH https://jakun.dk/api/v1/lead/3f1c2a9e-8d3b-4c55-9a51-2e0c0b7f4d11 \
  -H "Authorization: Bearer $JAKUN_TOKEN" -H "Content-Type: application/json" \
  -d '{"stage": "contacted"}'
lead = httpx.post(f"{URL}/api/v1/lead", headers=H, json={
    "title": "Nyt badeværelse 8 m²", "stage": "new", "source": "website"}).json()
httpx.patch(f"{URL}/api/v1/lead/{lead['id']}", headers=H, json={"stage": "contacted"})

Values are validated against the metadata: required fields, options, e-mail and Danish phone formats, number limits, links to other records. A bad value answers 422 validation_failed with the field in details. Money is {"amount": 4999900, "currency": "DKK"} in minor units (øre); times are ISO 8601 UTC; ids are UUIDs.

Permissions#

You see and change exactly what the roles of the key or user allow — records, fields and actions. Integration keys can't delete; deleting is soft and restorable by a person.