Guide

Custom endpoints

Build endpoints that do more than create, read, update and delete: combine queries, checks, calculations and calls to other services, without writing server code.

What they are

A custom endpoint is a method and path, such as POST /checkout, plus a list of steps that run in order each time it is called. A step can find or change records, stop with an error, calculate something, or call another service. The last step decides what comes back.

You call it like any other endpoint of your project, at /api/v1/ plus its path, with your API key. Custom endpoints also appear in your project's API docs.

bash
curl -X POST https://YOUR_PROJECT.codefreeapi.com/api/v1/checkout \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"amount": 12.5, "product": "T-shirt"}'
If a custom endpoint has the same method and path as an entity endpoint, the custom endpoint answers.

Building one

  1. In your project, open Custom Endpoints and click New Endpoint.
  2. Start from a template (for example "List my records" or "Stripe checkout link") or from a blank endpoint.
  3. Choose the method and path, and who may call it: anyone with your API key, signed-in users, or admins.
  4. Add steps from the palette and drag them into order. Each step has a short name (its alias) that later steps use.
  5. Try it in the test run panel, then save.

Paths can contain parameters: in /orders/:id, the part after /orders/ becomes params.id.

Inputs and values

Wherever a step needs a value (a filter, a field of a new record, the response) you either type a fixed value or pick one of these:

ValueWhat it is
context.body.emailA field of the JSON request body
context.query.statusA query string parameter (?status=open)
context.params.idA path parameter (/orders/:id)
context.userIdThe signed-in user's id
context.user.emailThe signed-in user's email (also .role)
steps.cartThe result of the step with alias cart
steps.order.totalOne field of an earlier step's result

A filter whose value comes from the body or query string and wasn't sent is skipped, so ?status= can be optional. A missing user, path parameter or step value matches nothing, so a query filtered by context.userId never returns everybody's records when nobody is signed in.

Steps

StepWhat it doesResult
Find recordsRecords of an entity with filters, sorting and a limit (up to 100). Filter operators: = != > < >= <= in containsA list
Find one recordThe first record that matchesA record or null
Count recordsHow many records matchA number
TotalsCount, sum, average, smallest or largest of a field over matching records, optionally per value of another fieldA number, or [{ group, value }]
Create recordSaves a new record. The signed-in user becomes its ownerThe record
Update recordChanges fields of a record, by default only one the signed-in user ownsThe record
Delete recordRemoves a record, by default only one the signed-in user owns{ id, deleted: true }
CheckStops with your status and message unless a value exists, is missing, is (not) empty, or equals (or doesn't equal) another valuetrue
CalculateNamed formulas: totals, dates, textAn object with the names
HTTP requestCalls another service, see HTTP requests{ status, ok, body }
RespondThe status code and the JSON body to send back, built from fixed values and earlier results–
Pick a fieldThe unique values of one field of an earlier listA list
Filter a listKeeps the items of an earlier list that match conditionsA list

Without a Respond step, the endpoint returns the result of its last step with status 200.

Sorting and pages from the caller: tick Let callers sort and page on a Find records step and callers can add ?sort=-price (minus = descending), ?limit=20 (up to 100) and ?page=2.

Conditions, lists, counters

Only if (if / else)

Every step has Options → Only run if: a formula such as body.plan == "pro" or steps.existing == null. When it is false the step is skipped and its result is null. Two steps with opposite conditions give you an if / else.

For each item of a list

Create, update, delete and HTTP request steps can run once per item of a list: a list in the request body (e.g. body.items) or the result of an earlier step. Inside, pick values from Current item (item.name), also available in formulas as item. The result is the list of results. Up to 100 items per step.

Counters

An Update record step can add to numbers (likes, stock, points; use a negative number to subtract). The addition happens in one database operation, so two requests at the same moment both count.

Unique fields

Create and update steps respect a field's Unique setting and answer 409 when the value is taken.

All or nothing & schedules

All or nothing (on by default for new endpoints): if a step fails or a Check step stops the run, the records earlier steps created, changed or deleted are put back. Requests already sent by HTTP request steps can't be taken back, so put those last. Webhooks for the undone changes may already have been sent.

Run automatically every hour or every day, besides when called: there is no signed-in user and the body is empty, so use fixed values and formulas such as addDays(now(), -30), e.g. to delete old records or post a daily summary with an HTTP request step. The endpoint page shows when it last ran and whether it worked.

Formulas

Calculate steps hold named formulas, and HTTP request steps use formulas inside {{ }} placeholders. Formulas are a small, safe language: they can only read the request, the signed-in user and earlier steps.

NameContains
bodyThe request body, e.g. body.price
queryThe query string, e.g. query.page
paramsPath parameters, e.g. params.id
useruser.id, user.email, user.role, or null when nobody is signed in
stepsEarlier results, e.g. steps.cart or steps.ai.body.choices[0].message.content
Earlier namesNames defined above in the same Calculate step: total = subtotal + shipping
secretsProject secrets, only inside HTTP request steps

Syntax

  • Numbers 12.5, text "hello" or 'hello', true, false, null and lists [1, 2, 3]
  • Arithmetic + - * / %. + with text joins it: "Total: " + total
  • Comparisons == != < <= > >=, logic && || !, and condition ? a : b
  • Fields with .name and list items with [0]

Functions

GroupFunctionsExample
Numbersround(n, digits), floor(n), ceil(n), abs(n), min(…), max(…), number(v)round(body.price * 1.25, 2)
Texttext(v), upper(s), lower(s), trim(s), concat(…), substring(s, start, end), replace(s, find, with), slug(s), split(s, sep), join(list, sep), length(v)slug(body.title)
Checkscontains(textOrList, part), startsWith(s, part), isEmpty(v), coalesce(a, b, …), if(test, then, else)coalesce(body.name, "friend")
Datesnow(), today(), date(d), datetime(d), addMinutes(d, n), addHours(d, n), addDays(d, n), diffDays(a, b), diffMinutes(a, b)addDays(today(), 14)
Listscount(list), sum(list, "field"), avg(list, "field"), first(list), last(list), pluck(list, "field")sum(steps.cart, "price")
Otheruuid(), randomCode(length)randomCode(6)

Good to know

Dates are ISO text such as 2026-11-03 or 2026-11-03T09:00:00.000Z, in UTC. Results are rounded to 15 significant digits, so 19.99 * 5 is 99.95, not 99.94999999999999. A missing field is null, never an error.

HTTP requests & secrets

An HTTP request step calls another service from the server: send an email, create a payment, ask an AI model. Set the method and URL, then headers, query parameters and a body: JSON, form (what Stripe expects) or text. Any of them can contain {{ formula }} placeholders.

JSON body
{
  "personalizations": [{ "to": [{ "email": {{ body.to }} }] }],
  "from": { "email": "[email protected]" },
  "subject": {{ "Welcome, " + coalesce(body.name, "friend") + "!" }},
  "content": [{ "type": "text/plain", "value": "Thanks for signing up." }]
}

No quotes around placeholders in JSON

In a JSON body, a placeholder becomes a JSON value: text gets quotes and escaping for you, numbers stay numbers. Write "email": {{ body.to }}, not "email": "{{ body.to }}". In the URL and query parameters, values are URL-encoded.

The step's result is { status, ok, body }, with body parsed from JSON when possible. Later steps use it, for example steps.session.body.url. If the service answers with an error status, the endpoint stops with 502, unless you tick "Continue when the service answers with an error".

Secrets

API keys of other services go in Secrets, on the Custom Endpoints page or in the builder. Use them as {{ secrets.NAME }}, usually in a header:

http
Authorization: Bearer {{ secrets.STRIPE_SECRET_KEY }}
  • Values are stored encrypted, and after saving only the last 4 characters are shown.
  • Secrets can only be used in HTTP request steps, never in responses or other steps.
  • If a service echoes a secret back, it is replaced by •••• in your endpoint's response and test runs.
  • Names use capital letters, digits and underscores, like OPENAI_API_KEY.

Limits

  • Only http and https on the standard ports (80 and 443).
  • Private, internal and cloud metadata addresses are blocked, including names that point to them.
  • Redirects aren't followed. Each call has 10 seconds and a 1 MB response.
  • Up to 1,000 HTTP requests per project per day.

Testing

The test run panel next to the builder runs the endpoint as it is in the editor, before you save. Fill in the path parameters, query string and body, and pick which of your users is signed in (or nobody).

  • Create, update and delete steps are simulated, so no data changes.
  • HTTP requests are simulated too, showing the request that would be sent, unless you tick "Send HTTP requests for real". Then emails really go out and payments are really created.
  • Each step's result is listed, so you can see where something went wrong.

Examples

My open tasks

GET /my-tasks, signed-in users. Templates: "List my records".

Steps
1. Find records   alias: tasks
   entity tasks, where ownerId = context.userId and done = false, sort dueDate
2. Respond        200 { "tasks": steps.tasks }

Order with total and delivery date

POST /orders, signed-in users. The body is { "productId": "…", "quantity": 3 }.

Steps
1. Find one record   alias: product
   entity products, where id = context.body.productId
2. Check             steps.product exists, else 404 "Product not found"
3. Calculate         alias: calc
   total    = round(steps.product.price * body.quantity, 2)
   delivery = addDays(today(), 3)
4. Create record     alias: order
   entity orders: product = context.body.productId, quantity = context.body.quantity,
                  total = steps.calc.total, deliveryDate = steps.calc.delivery
5. Respond           201 { "order": steps.order }

Stripe checkout link

POST /checkout, signed-in users. Needs the secret STRIPE_SECRET_KEY. Template: "Stripe checkout link".

Steps
1. Calculate      alias: price     cents = round(body.amount * 100)
2. HTTP request   alias: session
   POST https://api.stripe.com/v1/checkout/sessions
   Authorization: Bearer {{ secrets.STRIPE_SECRET_KEY }}
   form body:
     mode                                           payment
     success_url                                    https://yourapp.com/thanks
     line_items[0][quantity]                        1
     line_items[0][price_data][currency]            eur
     line_items[0][price_data][unit_amount]         {{ steps.price.cents }}
     line_items[0][price_data][product_data][name]  {{ body.product }}
     client_reference_id                            {{ user.id }}
3. Respond        200 { "url": steps.session.body.url }

Other templates in the builder: get one by id, create as signed-in user, update and delete my record, search, send an email with SendGrid, and ask an OpenAI model.

Errors and limits

StatusWhen
400A formula fails, for example a date that isn't a date, or a Check step with status 400
401 / 403Nobody signed in, or not an admin, see access rules
404No endpoint with this method and path, or a Check step with status 404
500A secret used by an HTTP request step isn't set
502An HTTP request step failed or the service answered with an error
409A create or update step would repeat the value of a unique field
413A run would read more than 5,000 records, change more than 500, or loop over more than 100 items
504A step took longer than 15 seconds

Every error answers { "error": "message" }. Check steps use the status and message you chose.