# API request builder

> Build Advanzo REST API requests in the browser and copy them as cURL, JavaScript, Python or PHP: list, filter, create, update, delete.

Put together a call to the Advanzo [REST API](https://www.advanzo.ch/docs/sections/api) and copy it as cURL, JavaScript, Python or PHP. Choose a resource and an operation; the builder shows the method, the URL and the code. It follows the conventions of the API reference, so what you build here works against your workspace once you add your token.

## What the builder covers

| Operation | Request | Notes |
| --- | --- | --- |
| List | `GET /api/{resource}` | Paginated. Supports search, sorting, relations and filter rules. |
| Get one record | `GET /api/{resource}/{id}` | Returns the record with its available actions. |
| Create | `POST /api/{resource}` | JSON body. Answers with `201`. |
| Update | `PUT /api/{resource}/{id}` | JSON body with the fields to change. |
| Delete | `DELETE /api/{resource}/{id}` | Answers with `204`. |
| Get the create fields | `GET /api/{resource}/create-fields` | The fields `POST` accepts, including your custom fields. |

## List options

| Field in the builder | Query parameter | Example |
| --- | --- | --- |
| Search term | `q` | `?q=Bürki` |
| Sort by, Direction | `order` | `?order=created_at\|desc` |
| Include relations | `with` | `?with=companies;deals` |
| Records per page | `per_page` (default 15) | `?per_page=100` |
| Page | `page` | `?page=3` |
| Filter rule | `filters`, JSON-encoded | One rule: field, type, operator, value |

The builder creates one filter rule. For several rules, or groups combined with `or`, write the rule tree by hand as shown under [Filter rules](https://www.advanzo.ch/docs/sections/api#filters). For `between`, `in` and their negations, enter the values separated by commas. Field names differ per workspace because of custom fields: fetch them with "Get the create fields" or with `GET /api/{resource}/rules`.

## Example

The ten largest deals, largest first:

```
curl "https://advanzo.app/api/deals?order=amount%7Cdesc&per_page=10" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json"
```

## Before you run a request

1. Ask a workspace admin to enable API access for your user, or be a super admin.
2. Open your user menu, then **Personal Access Tokens**, and create a token. It is shown once.
3. Replace `YOUR_ACCESS_TOKEN` in the cURL command, or set the environment variable `ADVANZO_TOKEN` for the other languages.

> **Warning:** A token gives full API access with the rights of its user. Keep it in a secret manager or an environment variable, never in client-side code or a repository. The builder does not ask for it.

## Frequently asked questions

Does the builder send requests to Advanzo?

No. It only writes the request as code. Nothing you type leaves your browser, and it never sees your token.

Why does my list request return only 15 records?

Because 15 is the default page size. Set "Records per page" (the `per_page` parameter) and read further pages with `page`.

How do I find the field names for a filter or a body?

Call `GET /api/{resource}/create-fields` for the fields a create accepts, and `GET /api/{resource}/rules` for the fields you can filter on. Both include your custom fields.

What is the rate limit?

90 requests per minute per user. A request over the limit returns `429 Too Many Requests` with a `Retry-After` header.
