# Farkitect API: the complete guides OpenAPI file: https://api.farkitect.com/openapi.json · Interactive reference: https://api.farkitect.com/docs # The Farkitect API Source: https://docs.farkitect.com/api/overview/ The Farkitect API lets programs of your own work with your models: a script that writes a report or a document from a package, a dashboard, another system kept in step with Farkitect. Your program presents an **API key** made in Organisation › Developers, and calls the API over HTTPS with JSON. ## Early access The API is in **early access**. It's **free** for every organisation while in early access; a paid plan will be needed later, and you'll be told well before that applies. During early access it grows phase by phase: | Available | What you can do | |---|---| | Now | Read projects, metamodels, models, views, a whole package in one call, a diagram's drawing data, the integrity check, and `.farki` exports. [Change models](https://docs.farkitect.com/api/models/changing/): make, change, move and delete packages, elements and relationships, with their values, up to 200 changes in one call, large deletes in the background, and a list of what was deleted | | Next | Attaching files | | Later | Import, webhooks to hear about changes as they happen, and apps other organisations connect to | The [changelog](https://docs.farkitect.com/api/changelog/) lists each change as it arrives. ## Where it is | | | |---|---| | Address | `https://api.farkitect.com/v1` | | Interactive reference | [api.farkitect.com/docs](https://api.farkitect.com/docs): every endpoint, with a **Send** button to try it with your key | | OpenAPI file | [api.farkitect.com/openapi.json](https://api.farkitect.com/openapi.json), for code generators and AI assistants | | For AI assistants | [docs.farkitect.com/llms.txt](https://docs.farkitect.com/llms.txt) and [llms-full.txt](https://docs.farkitect.com/llms-full.txt) | ## How it behaves - **JSON in and out**, UTF-8. Field names are camelCase, ids are opaque strings, dates are ISO 8601 in UTC. - **Keys go in the `Authorization` header**: `Authorization: Bearer fk_live_…`. Never in the address, and never in a web page: the API refuses calls from browsers. See [API keys](https://docs.farkitect.com/api/keys/). - **Errors** are RFC 9457 problems with a stable `code` and a request id. See [Errors](https://docs.farkitect.com/api/errors/). - **Rate limits** keep one program from crowding out others. Every response says where you stand. See [Rate limits](https://docs.farkitect.com/api/rate-limits/). - **The same rules as the app.** A key acts as a member of the project with its role (viewer, contributor or admin), so it can see and do exactly what a person with that role can. ## Versions The version is in the path: `/v1`. **v1 is a preview.** The API is still being shaped, so until it is declared stable a change may break a working program: a field renamed or reshaped, say. Every such change is marked **Breaking** in the [changelog](https://docs.farkitect.com/api/changelog/), so check it when you update. **Ignore fields and values you don't recognise**; most changes are additions, and your program keeps working through them. It will be declared stable once developers outside Farkitect build on it; if you are about to, [tell us](https://docs.farkitect.com/how-to/contact-support/) and we'll settle it with you first. Once v1 is declared stable, with notice in the changelog, changes within it will only be additions: new endpoints, new fields, new error codes, new values in lists. A change that could break a working program would then come as `/v2`, with v1 kept running for at least a year. ## Next [Quick start](https://docs.farkitect.com/api/quick-start/): a key and your first call, in five minutes. # API quick start Source: https://docs.farkitect.com/api/quick-start/ ## 1. Make a key You need to be one of your organisation's owners or admins, or the admin of a project (for a key to that project only). 1. On the website, open **Organisation Settings** and go to the **Developers** tab. 2. Choose **New key**. Give it the name of the program that will use it, such as *Architecture report*. 3. Choose what it **reaches** (the whole organisation, or one project), its **role** (Viewer is enough for reading), and when it **expires**. 4. Choose **Make key**, then **Copy key**. The key is shown only this once: Farkitect keeps only a fingerprint of it. If it's lost, make another. A production key starts `fk_live_`. ## 2. Try it in your browser No terminal needed. 1. Open the [interactive reference](https://api.farkitect.com/docs). 2. Paste your key into **Bearer Token**, under Authentication. 3. On **The key making the request**, choose **Test Request**, then **Send**. You should see **200 OK** and your key: its name, organisation, role, expiry, and the projects it reaches. ## 3. Call it from a program Keep the key out of your code: put it in an environment variable. **In a terminal** (macOS, Linux, or Windows with Git Bash): ```sh export FARKITECT_API_KEY='fk_live_…' curl https://api.farkitect.com/v1/me -H "Authorization: Bearer $FARKITECT_API_KEY" ``` **In Python** (with `requests`): ```python import os, requests response = requests.get( "https://api.farkitect.com/v1/me", headers={"Authorization": f"Bearer {os.environ['FARKITECT_API_KEY']}"}, ) response.raise_for_status() me = response.json() print(me["name"], [p["name"] for p in me["projects"]]) ``` **In TypeScript or JavaScript** (Node 18 or later): ```ts const response = await fetch("https://api.farkitect.com/v1/me", { headers: { Authorization: `Bearer ${process.env.FARKITECT_API_KEY}` }, }); if (!response.ok) throw new Error(`${response.status}: ${(await response.json()).detail}`); const me = await response.json(); console.log(me.name, me.projects.map((p) => p.name)); ``` ## 4. See it in Developers Back in **Organisation Settings › Developers**, your key shows when it was **last used**. Within ten minutes, **Usage** counts today's requests, and any that failed appear under **Failed requests**, with their request ids. ## 5. Read a project Next, list the projects your key reaches, then the metamodels of one of them: ```sh curl https://api.farkitect.com/v1/projects -H "Authorization: Bearer $FARKITECT_API_KEY" curl https://api.farkitect.com/v1/projects/PROJECT_ID/metamodels -H "Authorization: Bearer $FARKITECT_API_KEY" ``` **Finding an id in the app:** right-click any row in the Explorer or the Views panel, or a shape on a diagram, and choose **Copy Id**; the open project's id is in **Help › About Farkitect**. No project to try it on? Add the sample project, Farquind Yachts, from the Farketplace. [Projects](https://docs.farkitect.com/api/projects/) and [Metamodels](https://docs.farkitect.com/api/metamodels/) explain what comes back, and [Lists and paging](https://docs.farkitect.com/api/lists/) how to page through long lists. ## If it doesn't work | You get | Because | Do | |---|---|---| | 401 [`missing_key`](https://docs.farkitect.com/api/errors/missing-key/) | No key was sent | Check the `Authorization` header, and that the environment variable is set in the shell running the program | | 401 [`invalid_key`](https://docs.farkitect.com/api/errors/invalid-key/) | The key isn't recognised | Check it was copied whole; make a new one if it's lost | | 403 [`browser_not_allowed`](https://docs.farkitect.com/api/errors/browser-not-allowed/) | It was called from a web page | Call it from a server: see [Build with an AI assistant](https://docs.farkitect.com/api/build-with-ai/#web-apps-keep-the-key-on-a-server) | | 429 [`rate_limited`](https://docs.farkitect.com/api/errors/rate-limited/) | Too many requests, or too many at once | Wait the seconds in `Retry-After`, and send requests one after another | Every error explains itself in its `detail`; [Errors](https://docs.farkitect.com/api/errors/) lists them all. # API keys Source: https://docs.farkitect.com/api/keys/ An API key belongs to an **organisation**, not to a person. It acts like a member of a project with one role, so a program using it can see and do what a person with that role can, and its changes are signed **API · *key name*** wherever Farkitect shows who changed something. Keys are for programs. To give a person access, invite them to the organisation or the project instead. ## Two kinds of key | | Whole organisation | One project | |---|---|---| | Reaches | Every project in the organisation, including ones made later | Exactly one project | | Made by | The organisation's owners and admins | Its owners and admins, and that project's admins | | Typical use | Reports and dashboards across everything | A tool for one team, or a product bought for one project | A key never reaches another organisation, the organisation's settings or its members. ## Roles | Role | The key may | |---|---| | Viewer | Read | | Contributor | Read, and change models (M1) | | Admin | As a project admin. For now the API only reads metamodels; metamodels are changed in the modeler | Give a key the least it needs: for reports and documents, **Viewer**. ## Making, extending and revoking Everything is in **Organisation Settings › Developers**. Owners and admins see every key in the organisation; a project's admins see the keys for their projects. Every member of a project can see, on the project's **Members** tab, which keys reach it. - **Make** a key: see the [quick start](https://docs.farkitect.com/api/quick-start/). It's shown once. - **Expiry**: every key expires, after 30 days, 90 days (the default), 6 months or a year. A week before, whoever made it and whoever can manage it are emailed. - **Extend** gives it up to another year from today. **It stays the same key**, so nothing needs changing in the program using it. - **Revoke** stops it at once, everywhere. It can't be undone. - **Rotate** a key by making a second one, moving the program to it, then revoking the first. Both work in between. When someone leaves the organisation or a project, or stops being an admin, the keys they made keep working: programs shouldn't stop because a person moved on. Whoever makes the change is shown the keys that person made, and offered the chance to replace them, since that person has seen them. ## Keeping a key safe - Keep it in an **environment variable** or a secrets manager, never in code. A key pushed to a public repository can be found within minutes. - Send it only in the `Authorization` header. A key in an address is refused, and should be treated as leaked: revoke it. - Never put it in a web page or a browser app: anyone using the page could read it, and the API refuses calls from browsers. For a web app, keep the key on a server: see [Build with an AI assistant](https://docs.farkitect.com/api/build-with-ai/#web-apps-keep-the-key-on-a-server). - One key per program, so each can be revoked without stopping the others. Keys start `fk_live_` (production) or `fk_test_` (Farkitect's test deployments), so a key is easy to recognise if it turns up somewhere it shouldn't. # Lists and paging Source: https://docs.farkitect.com/api/lists/ Every call that returns many items, such as projects, elements or views, returns them a page at a time, in this shape: ```json { "object": "list", "data": [ … ], "hasMore": true, "nextCursor": "eyJ2IjoxLCJsIjoi…" } ``` To read a whole list, ask again with `cursor` set to `nextCursor` until `hasMore` is false: ```python import os, requests def read_all(path): items, cursor = [], None while True: response = requests.get( f"https://api.farkitect.com{path}", params={"limit": 200, **({"cursor": cursor} if cursor else {})}, headers={"Authorization": f"Bearer {os.environ['FARKITECT_API_KEY']}"}, ) response.raise_for_status() page = response.json() items += page["data"] if not page["hasMore"]: return items cursor = page["nextCursor"] ``` Three rules: - **Never assume a page is full.** `limit` (1 to 200, default 50) is the most a page holds. A page can hold fewer, even none, while more follow: Farkitect stops a page early when reading it would take too long, such as types with many property types. Only `hasMore` says whether there's more. - **Pass `nextCursor` back exactly as it came**, to the same list. A cursor that's been changed, or taken to another list, gets 400 [`invalid_cursor`](https://docs.farkitect.com/api/errors/invalid-cursor/). - **Read pages one after another.** A key may have only a few requests running at once ([Rate limits](https://docs.farkitect.com/api/rate-limits/)), and pages depend on each other anyway. Lists aren't one snapshot: a change made while you page through can appear or not. For a consistent read, note the time before you start and compare `updatedAt` afterwards. ## Filters Many lists take filters, such as `type`, `packageId` or `updatedSince`. Filters combine, and each id must be from the project: an id from elsewhere, or of the wrong kind, gets 404 [`not_found`](https://docs.farkitect.com/api/errors/not-found/) naming the filter, so a typing slip isn't mistaken for "nothing matches". A cursor works only with the filters it came from. # Projects Source: https://docs.farkitect.com/api/projects/ A key reaches every project of its organisation, or exactly one project, as it was made ([API keys](https://docs.farkitect.com/api/keys/)). | Call | Gives | |---|---| | `GET /v1/projects` | The projects the key reaches: every project of its organisation, or its one project | | `GET /v1/projects/{projectId}` | One project: name, description, when it was made and last changed, and the key's role in it | A project's `updatedAt` follows edits to its model, as the website's **Modified** does, so a program can tell whether there's anything new to read. ## Try it on sample data To try the API without touching real work, add the sample project, **Farquind Yachts**: on the website, open the **Farketplace**, choose **Archimate Enterprise Architecture Starter**, and choose **Create Project**: it becomes a project in your organisation. It's a complete model of a yacht builder: hundreds of elements and relationships, diagrams, and property values. A key that reaches your whole organisation reaches it at once; for a one-project key, make one for the new project. Next: what a project's models are made of, [Metamodels](https://docs.farkitect.com/api/metamodels/), and the models themselves: [Reading models](https://docs.farkitect.com/api/models/reading/) and [Changing models](https://docs.farkitect.com/api/models/changing/). Every list is paged the same way: [Lists and paging](https://docs.farkitect.com/api/lists/). # Metamodels Source: https://docs.farkitect.com/api/metamodels/ A model's elements are of types defined by its **metamodel** (M2): element types, relationship types, the property types they carry, and the enumerations that some property types use. Before a program reads or reports on a model, it usually needs to know these. | Call | Gives | |---|---| | `GET /v1/projects/{projectId}/metamodels` | The project's metamodels, `standard` and `common` | | `GET /v1/metamodels/{metamodelId}` | One metamodel, with its layers in the order the app shows them | | `GET /v1/metamodels/{metamodelId}/element-types` | Every element type, layer by layer, with its property types | | `GET /v1/metamodels/{metamodelId}/relationship-types` | Every relationship type, with its verbs and the element types it may join | | `GET /v1/metamodels/{metamodelId}/enumerations` | Every enumeration, with its values in order | Metamodels are read only in the API: they're changed in the app, where the careful paths are (upgrades, value alignment, backups). ## Included metamodels A metamodel can be **included** from another project of the organisation: defined once there, and a read-only copy here that takes new versions when an admin accepts them (see [How to share a metamodel between projects](https://docs.farkitect.com/how-to/include-metamodel/)). Such a metamodel has `included`: - `sourceProjectId`: the project it is included from; `originProjectId`: the project that defines it. They differ when it comes through another project's copy. - `version` and `label`: the published version it holds. - `state`: `upToDate`; `waiting` (a newer version is published and not yet accepted); `updating`; `failed` (an update stopped part-way); or `sourceGone` (the project it came from no longer offers it). `included` is null for the project's own metamodels. Its types and values read as any other's; their ids are this project's. A **model** can be included the same way. Its top-level package then has the same `included` field, every item in it has `originUid` (the original's `uid`), and writes to it or to anything in it are refused with `403 forbidden`. Relationships from the project's own elements to its elements can be made as usual. ## Property types Each element and relationship type lists its **property types**, its own and those it inherits from its superclasses, in the order the app shows them. For each: - `dataType`: `String`, `Integer`, `Real`, `Boolean`, `Date`, `DateTime`, `UnlimitedNatural`, `Enumeration` (then `enumeration` names which one) or `Element` (a reference to an element of `elementType`). - `format`: how a value is shown or entered, such as `multiline`, `url`, `email`, `richtext` (Markdown), `currency:NZD` or `percent`. New formats may appear; treat one you don't know as plain text. - `multiplicity`: `lower` 1 or more means a value is required; `upper` null means no limit. - `defaultValue`, and `inheritedFrom`: the superclass it comes from, or null when it's the type's own. ## What an element can have attached An element type's `attachment` says what its elements may have [attached](https://docs.farkitect.com/api/models/changing/#attaching-files): `image` (images only), `file` (any file), or null when they can't have one. Check it before sending a file, rather than waiting for a 422. ## Enumeration values Each value has a `name`, as people see it, and a `storedValue`, which is what's stored and never changes when the value is renamed. Match on `storedValue` in your program; show `name` to people. ## Retired types and values A type, property type or value can be **retired** by a metamodel upgrade: existing elements and values are kept, but nothing new should use it. `retired` then says since which metamodel version, and why if a reason was given; otherwise it's null. ## Valid pairs A relationship type's `validPairs` lists the element types it may join, source to target. A null end means any type, and `validPairs: null` means any pair at all. A subtype is accepted wherever its superclass is: check against an element type and its superclasses. # Reading models Source: https://docs.farkitect.com/api/models/reading/ A project's **models** hold its packages, elements and the relationships between them. This page is about reading them, with a key of any role; [Changing models](https://docs.farkitect.com/api/models/changing/) is about changing them. Each element and relationship is of a type from a metamodel, and carries **property values** for that type's property types. Read [Metamodels](https://docs.farkitect.com/api/metamodels/) first for the types, and [Lists and paging](https://docs.farkitect.com/api/lists/) for how lists are paged. | Call | Gives | |---|---| | `GET /v1/projects/{projectId}/packages` | The model packages, as a flat list | | `GET /v1/projects/{projectId}/elements` | Elements, filtered as you choose | | `GET /v1/elements/{elementId}` | One element, with all its values | | `GET /v1/elements/{elementId}/attachment` | The file attached to an element | | `GET /v1/projects/{projectId}/relationships` | Relationships, filtered as you choose | | `GET /v1/relationships/{relationshipId}` | One relationship, with all its values | | `GET /v1/packages/{packageId}/contents` | A whole package at once: everything below it, values included | | `GET /v1/packages/{packageId}/markdown` | A whole package as one Markdown document | ## A whole package at once For a report, a document or an analysis, it's usually simplest to read a whole package in one call. `GET /v1/packages/{packageId}/contents` gives the package and everything below it: `packages`, `elements` and `relationships`, each exactly as the single-item calls give it, values included. Give a model's own id to read the whole model. `include=metamodel` adds the types the items are of, and the enumerations their property types use. `GET /v1/packages/{packageId}/markdown` gives the same package as one Markdown document, as **Export as Markdown** writes it in the app: ready for a document, or to hand to an AI. These are **heavy calls**: an organisation may make a few a minute, one at a time ([Rate limits](https://docs.farkitect.com/api/rate-limits/)). A package too large for one call, over 10 MB or 45 seconds to gather, gets 413 [`use_export_job`](https://docs.farkitect.com/api/errors/use-export-job/): [export it](https://docs.farkitect.com/api/exports/) instead, or read it a page at a time with the calls below. The answer isn't one snapshot: changes made while it's gathered may or may not be in it. Its `startedAt` says when it began, so follow up with `updatedSince` set to that to catch them. ## Packages Packages come as a flat list. Each names its `parentId`, which is null for a **model**, a top-level package. Build the tree by grouping on `parentId`. `rootId` keeps only one package and those below it. ## Elements and their values A list of elements gives each one's name, package, type (with its metamodel), notes and dates. Add `include=properties` for their values too. Lists with values hold at most 50 elements a page, since each reads more. A single element (`GET /v1/elements/{elementId}`) always comes with its values and its attachment's details. `properties` holds every property type of the element's type, by name, with the element's value: ```json "properties": { "Annual Cost": { "propertyTypeId": "r10…", "dataType": "Real", "format": "currency:NZD", "value": 125000, "storedValue": null, "fits": true }, "Lifecycle": { "propertyTypeId": "r09…", "dataType": "Enumeration", "format": null, "value": "In production", "storedValue": "production", "fits": true }, "Go Live": { "propertyTypeId": "r11…", "dataType": "Date", "format": null, "value": "2025-03-01", "storedValue": null, "fits": true }, "Owner": { "propertyTypeId": "r12…", "dataType": "String", "format": null, "value": null, "storedValue": null, "fits": true } } ``` - **`value`** is in its natural type: a number for Integer, Real and UnlimitedNatural (`"*"` means no limit), `true` or `false` for Boolean, `YYYY-MM-DD` for Date, ISO 8601 in UTC for DateTime, and text otherwise (Markdown when `format` is `richtext`). It's null when the element has no value. - **Enumerations** give the value's name in `value`, as people see it, and the value as stored in `storedValue`, which never changes when the value is renamed. Match on `storedValue`. - **Values are listed by property type name**, which is easy to read, but a name can change: when someone renames a property type in the app, its value comes under the new name. A program that keeps values should match on **`propertyTypeId`**, which never changes, and use the name only to show people. Setting values works with either (see [Changing models](https://docs.farkitect.com/api/models/changing/)). - **`fits`** is false when a stored value doesn't fit its data type, such as text in a number after the metamodel changed. The value then comes as stored text. Show it, but don't calculate with it. ## Filters Elements filter by `type` (an element type's id), `packageId` (the elements directly in a package) and `updatedSince`. Relationships filter by `type`, `sourceId`, `targetId`, `elementId` (either end) and `updatedSince`. How filters and pages work for every list: [Lists and paging](https://docs.farkitect.com/api/lists/). ## Keeping another system in step `updatedSince` gives what changed at or after a time, **oldest change first**. An element counts as changed when anything about it changes, its values included, whoever or whatever changed them. To keep another system in step: 1. The first time, read everything, and note when you started. 2. Each time after, ask for `updatedSince` the time you noted last, and note the new time before you start. 3. Apply what comes back in order. Reading from slightly before the last time does no harm: changes come again, never get lost. ```python import os, requests from datetime import datetime, timezone API = "https://api.farkitect.com/v1" HEADERS = {"Authorization": f"Bearer {os.environ['FARKITECT_API_KEY']}"} def changed_since(project_id, since): started = datetime.now(timezone.utc).isoformat() params, items = {"updatedSince": since, "include": "properties", "limit": 50}, [] while True: page = requests.get(f"{API}/projects/{project_id}/elements", params=params, headers=HEADERS) page.raise_for_status() body = page.json() items += body["data"] if not body["hasMore"]: return items, started # keep `started` for next time params["cursor"] = body["nextCursor"] ``` **Deletions** don't appear in `updatedSince`: a deleted item isn't there to list. Ask `GET /v1/projects/{projectId}/deletions?since=…` with the same time instead. It lists every package, element, relationship and view deleted since then, oldest first, however it was deleted: in the app, by a program, by an import or a metamodel upgrade. ```json { "object": "deletion", "kind": "element", "id": "j57c9w3…", "deletedAt": "2026-11-09T03:12:40.000Z" } ``` Deletions are remembered for **30 days**. A `since` further back gets `410` [`resync_required`](https://docs.farkitect.com/api/errors/resync-required/): some deletions are no longer known, so read everything again, note the time you started, and carry on from there. ## Relationships Each relationship gives its type, its `source` and `target` elements by id and name, and with `include=properties` its values. `elementId` gives every relationship at either end of an element; a relationship from an element to itself is listed once. ## Attachments An element with an attached file says so in `attachment` (file name, type and size). `GET /v1/elements/{elementId}/attachment` returns the file itself, with its type in `Content-Type` and its name in `Content-Disposition`: ```sh curl -OJ https://api.farkitect.com/v1/elements/ELEMENT_ID/attachment -H "Authorization: Bearer $FARKITECT_API_KEY" ``` # Changing models Source: https://docs.farkitect.com/api/models/changing/ This page is about changing a project's models; [Reading models](https://docs.farkitect.com/api/models/reading/) is about reading them. A program can change a project's models as a person can in the app: make packages, elements and relationships, set their values, attach files, rename and move them, and delete them, one at a time or up to 200 in one call. Every change goes through the same rules as the app's, and is signed with the key's name (`API · `) wherever the app shows who changed something. Changing needs a key with the **contributor** or **admin** role for the project ([API keys](https://docs.farkitect.com/api/keys/)). Metamodels can't be changed through the API: they're read only ([Metamodels](https://docs.farkitect.com/api/metamodels/)). | Call | Does | |---|---| | `POST /v1/projects/{projectId}/packages` | Makes a package inside a model | | `GET /v1/packages/{packageId}` | Gives one package, with its `ETag` | | `PATCH /v1/packages/{packageId}` | Renames it, changes its notes, or moves it | | `DELETE /v1/packages/{packageId}` | Deletes it, with everything in it | | `POST /v1/projects/{projectId}/elements` | Makes an element, with its values | | `PATCH /v1/elements/{elementId}` | Changes its name, notes or values, or moves it | | `DELETE /v1/elements/{elementId}` | Deletes it, with its relationships and diagram shapes | | `POST /v1/projects/{projectId}/relationships` | Makes a relationship between two elements | | `PATCH /v1/relationships/{relationshipId}` | Changes its name, notes, values or ends | | `DELETE /v1/relationships/{relationshipId}` | Deletes it | | `PUT /v1/elements/{elementId}/attachment` | Attaches a file to an element, replacing any it had | | `DELETE /v1/elements/{elementId}/attachment` | Removes an element's attached file | | `POST /v1/projects/{projectId}/batch` | Makes up to 200 of these changes at once, all or none | To notice what others deleted, see [Keeping another system in step](https://docs.farkitect.com/api/models/reading/#keeping-another-system-in-step). ## Making an element ```sh curl -X POST https://api.farkitect.com/v1/projects/$PROJECT/elements \ -H "Authorization: Bearer $FARKITECT_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "type": "M2 ArchiMate 4/Application Component", "name": "Customer Portal", "packageId": "m88…", "notes": "Serves **retail** customers.", "properties": { "Annual Cost": 125000, "Lifecycle": "Production", "Go Live": "2025-03-01" } }' ``` The answer is `201` with the element as `GET /v1/elements/{elementId}` gives it, its address in `Location` and its version in `ETag`. - **`type`** is the element type's id, or its name as `"Metamodel/Type name"`, or a type name alone when only one metamodel the model imports has a type of that name. - **`packageId`** is where to put it. For an element that belongs to another, such as an attribute, give **`ownerId`** instead: it's kept in its owner's package. - **`properties`** are set by property type name (or id), each in its natural type, as values are read ([Reading models](https://docs.farkitect.com/api/models/reading/#elements-and-their-values)): a number, `true` or `false`, `YYYY-MM-DD` for a date, an enumeration value's name. `null` clears a value. Property types not given keep their type's default. The element must be one the model can hold, as in the app. It's refused, with the reason, when its type is: - **abstract** (it can't have elements of its own) or **retired**; - a **relationship type**; - from a metamodel **the model doesn't import** (add the import in the app, in the model's Properties); - a **subordinate type** (such as an attribute) without an owner whose type has it. A value that doesn't fit its property type is refused too. Nothing is made when anything is refused: the answer is `422` [`validation_failed`](https://docs.farkitect.com/api/errors/validation-failed/), and its `errors` name each field. ```json "errors": [ { "field": "body.properties.Annual Cost", "message": "must be a number" }, { "field": "body.properties.Lifecycle", "message": "must be one of \"Planned\", \"Production\", \"Retired\"" } ] ``` ## Changing and moving `PATCH` changes only what's sent. In `properties`, only the values sent change; `null` clears one. ```json { "name": "Customer Portal (retail)", "properties": { "Annual Cost": 130000, "Owner": null } } ``` To move an element, give `packageId` (another package) or `ownerId` (to put it under another element; `null` takes it out from under its owner, into the same package). A package moves with `parentId`. Moves follow the app's rules: nothing moves into itself, and a relationship whose ends both leave the model it's kept in moves with its source. ## Relationships ```json POST /v1/projects/{projectId}/relationships { "type": "M2 ArchiMate 4/Serving", "sourceId": "j57…", "targetId": "k12…", "properties": { "Criticality": "High" } } ``` `type` is given as for an element. Left unnamed, a relationship is named from its ends and its type's verb, as in the app ("Customer Portal serves Retail Banking"). It's kept in the source's package unless `packageId` names another package of the source's model. Its ends may be in two models: the type must then be from a metamodel that both models import, and each end in what the API returns says which model it is in (`source.model`, `target.model`). It's refused, with the reason, when its type can't join that pair, by the rules the app follows when you connect two shapes: - a standard metamodel's relationship type joins only that metamodel's elements; a common metamodel's (such as M2 Common) joins elements of the metamodels the model imports; - a type with **valid pairs** joins only those pairs of element types. A subtype counts as its supertype, so a pair for *Party* also allows a *Customer* that is a kind of Party. `PATCH` with `sourceId` or `targetId` joins it to another element, by the same rules. A name made from its ends follows the new ends; a name someone chose is kept. ## Many changes at once `POST /v1/projects/{projectId}/batch` makes up to 200 changes in one call, in order, **all or none**. Each operation names what to do (`op`: `create`, `update` or `delete`), to what (`kind`: `package`, `element` or `relationship`), and the body the single call takes. An update or delete names the item's `id`, and may give its `ifMatch`. A create may have a **`ref`**, a name starting with `$`, which stands for its new id in later operations. So elements and the relationships between them are made in one call: ```json { "operations": [ { "op": "create", "kind": "element", "ref": "$portal", "body": { "type": "Application Component", "name": "Customer Portal", "packageId": "m88…" } }, { "op": "create", "kind": "element", "ref": "$crm", "body": { "type": "Application Component", "name": "CRM", "packageId": "m88…" } }, { "op": "create", "kind": "relationship", "body": { "type": "Flow", "sourceId": "$crm", "targetId": "$portal" } }, { "op": "update", "kind": "element", "id": "q41…", "body": { "properties": { "Lifecycle": "Retired" } } } ] } ``` The answer lists each operation's result in order: its `id`, its `ref`, and the item as it is now (`null` for a delete). If any operation is refused, **nothing** is changed: the problem's `detail` names the operation ("Operation 2 (create relationship): …") and its `errors` name the fields, such as `body.operations[2].body.type`. Every item must be in the batch's project. A batch counts as one change against the per-minute limit, and its `Idempotency-Key` covers the whole batch. ## Attaching files `PUT /v1/elements/{elementId}/attachment` attaches a file to an element: the file itself is the body, its type is in `Content-Type`, and its name in `Content-Disposition`. It replaces any file the element had. The answer is the element as it is now, with the attachment's name, type and size, and its new `ETag`. ```bash curl -X PUT https://api.farkitect.com/v1/elements/ELEMENT_ID/attachment \ -H "Authorization: Bearer $FARKITECT_API_KEY" \ -H "Content-Type: application/pdf" \ -H 'Content-Disposition: attachment; filename="Service design.pdf"' \ --data-binary @"Service design.pdf" ``` As in the app, only an element whose **type allows an attachment** takes one, and a type whose attachments are images takes **images only**; anything else is refused with `422` saying why. A file can be at most **4 MB** through the API (`413` [`too_large`](https://docs.farkitect.com/api/errors/too-large/) otherwise); larger files can be attached in the app. Without `Content-Disposition` the file is called `attachment`; for a name with characters other than plain letters, send `filename*=UTF-8''` followed by the name, percent-encoded. `DELETE /v1/elements/{elementId}/attachment` removes the file; an element with none is left as it is. Both take `If-Match` and `Idempotency-Key`, as every change does. Reading a file back is [`GET /v1/elements/{elementId}/attachment`](https://docs.farkitect.com/api/models/reading/#attachments). ## Deleting `DELETE` takes what deleting in the app takes: a package with everything in it, an element with the elements it owns, its relationships and its shapes on diagrams, and a relationship with its connectors on diagrams. The answer is `204`. A delete that would take **more than 200** elements and relationships runs in the background instead: the answer is `202` with a **job**, and its address in `Location`. Ask `GET /v1/jobs/{jobId}` every few seconds until its `status` is `done`; `deleted` then says how many elements and relationships it deleted. It's the app's own delete, so it takes the same things with it. An organisation runs one job at a time, exports included ([Exports](https://docs.farkitect.com/api/exports/)). In a batch, a delete must be small: a larger one is refused with `413` [`too_large`](https://docs.farkitect.com/api/errors/too-large/). A whole model (a top-level package) is made and deleted in the app. ## Retrying safely: Idempotency-Key A request can time out after Farkitect made the change. Sent again, it would make it twice. To retry safely, send an `Idempotency-Key` header, any unique string (a UUID is usual), with every change: - the same request with the same key, within a day, gets the **first answer again**, and nothing is changed a second time; - the same key with a **different** request is refused with `422` [`idempotency_key_reused`](https://docs.farkitect.com/api/errors/idempotency-key-reused/); - a request that was refused stores nothing, so it can be put right and sent again with the same key. ## Not overwriting others: If-Match Someone may change an item between your program reading it and changing it. To change it only if nobody has, send its `ETag` back in `If-Match`: 1. Read it: `GET /v1/elements/{elementId}` (or `/v1/packages/{packageId}`) answers with an `ETag` header. Every change's answer has one too. 2. Send the change with `If-Match: `, exactly as it came. 3. If the item changed in between, nothing changes and the answer is `412` [`precondition_failed`](https://docs.farkitect.com/api/errors/precondition-failed/). Read it again, apply your change to what's there now, and send it with the new `ETag`. Without `If-Match`, a change is made whatever happened since. Both headers are optional, but a program that changes models for others should use both. ## Limits Each change counts against the key's changes per minute, as well as its requests ([Rate limits](https://docs.farkitect.com/api/rate-limits/)); a batch counts as one. To change many items, **send them in batches**, one batch after another: it's quicker for your program, uses fewer of its calls, and is kinder to the people who have the project open, whose app takes in each change as it happens (a batch arrives as one change). # Views Source: https://docs.farkitect.com/api/views/ | Call | Gives | |---|---| | `GET /v1/projects/{projectId}/views` | Every diagram, catalog, board and chart view, with what each shows | | `GET /v1/diagrams/{diagramId}` | A diagram's shapes, connectors and links to other views | | `GET /v1/diagrams/{diagramId}/drawing` | Everything the diagram shows, to draw it as the app does | The list gives every view of the project, diagrams first, then catalogs, boards and chart views. `kind` keeps one kind, and `packageId` keeps the views kept directly in a package. Each view gives its name, package and notes, and what it shows: - **Catalogs and boards:** `type`, the element type they list. A board also gives `groupBy`, the property type whose values make its columns. - **Catalogs, boards and chart views:** `scope`, the part of the project they show. Each rule names a package and whether it's included; the nearest rule on a package or above it decides. `null` means every model. **Catalog rows and board cards aren't given yet.** To read what a catalog shows, list the elements of its `type` with their values (`GET /v1/projects/{projectId}/elements?type=…&include=properties`), and keep those in its `scope`. Calls that give the rows exactly as the app arranges them may follow when programs need them. ## Diagrams `GET /v1/diagrams/{diagramId}` gives the diagram's: - **`nodes`:** each shape, with the element it draws (`id` and `name`), its position and size (`x`, `y`, `width`, `height`, in the diagram's own units), and `parentElementId` when it's drawn inside another element's shape. - **`edges`:** each connector, with the relationship it draws, the shapes it joins (`sourceNodeId`, `targetNodeId`) and its bend points (`waypoints`), in order from source to target. - **`links`:** each link to another view, with the view it opens (`kind` and `id`) and its label. This is the diagram's structure. To draw it, use its drawing data, below. ## Drawing a diagram `GET /v1/diagrams/{diagramId}/drawing` gives everything the diagram shows, so a program can draw it exactly as the app does: in a report, a document, a web page. | Part | Gives | |---|---| | `shapes` | Each shape: its element (`id`, `name`, `type`), position and size, the shape it's drawn inside (`parentShapeId`), its **final colours** (`fill`, `border`, `text`, `fold`) in `light` and `dark`, border, shadow, text alignment, label placement, its values when the diagram shows compartments, what it owns, its attachment, child diagrams, and whether it fits its metamodel | | `connectors` | Each connector: its relationship, the shapes it joins (`from`, `to`), routing and bend points, final line and label colours, width, pattern, its label text, role names and multiplicities | | `types` | Each type used, once, keyed by id: its notation already worked out (shape, fill mode, border, markers, compartments, property types) | | `icons` | Each type's icon, once, as SVG, keyed by the type's `icon` | | `links` | Each link to another view | | `diagram.settings` | What the diagram shows: connectors, connector labels (`name`, `verb`, `none`), compartments, stereotypes | Good to know: - **As saved.** Nobody's unsaved changes, and no selection. - **Both themes.** Every colour is given for `light` and `dark`; pick one. A connector's label colour is `null` when it uses the theme's label colours. - **Shapes and connectors that don't fit their metamodel** (`fitsMetamodel: false`) are drawn as the app draws them: their colours are the theme's muted ones, and `opacity` is 0.4. Every other shape and connector has `opacity` 1. - **Values** are in their natural types, as an [element's values](https://docs.farkitect.com/api/models/reading/) are. - **Attachment images** are never sent as addresses: fetch one from the shape's `attachment.href`, with your key. - **Redraw only what changed.** `version` changes whenever anything drawn changes, and is also the `ETag`. Send it back in `If-None-Match` exactly as you received it (a compressed answer's tag is weak, `W/"…"`), and an unchanged diagram answers **304** with no body. - **Format** `farkitect-drawing/1`. Fields may be added within it, as anywhere in the API. To turn this answer into the picture, the same as the app draws it, use Farkitect's drawing package or the `farkitect-render` tool: see [Drawing a diagram in your program](https://docs.farkitect.com/api/drawing/). # Drawing a diagram in your program Source: https://docs.farkitect.com/api/drawing/ A diagram's [drawing data](https://docs.farkitect.com/api/views/#drawing-a-diagram) (`GET /v1/diagrams/{diagramId}/drawing`) holds everything the diagram shows. Farkitect's own drawing code turns it into the picture, exactly as the app draws it, wherever your program runs: | You're writing | Use | You get | |---|---|---| | A web page (any framework, or none) | The drawing package, `@farkitect/draw` | The diagram on the page, or a PNG or SVG | | A program in any language (Python, Rust, C#, a shell script…) | The command-line tool, `farkitect-render` | PNG or SVG files | Nothing is drawn on Farkitect's servers: the picture is made where your program runs, from data it has just read, so it is always current. :::note Both are published on npm: [`@farkitect/render`](https://www.npmjs.com/package/@farkitect/render) and [`@farkitect/draw`](https://www.npmjs.com/package/@farkitect/draw), under the MIT licence. The API is a [preview](https://docs.farkitect.com/api/overview/#versions) until it is declared stable. ::: ## The command-line tool `farkitect-render` needs [Node.js](https://nodejs.org) 22 or later and Chrome or Chromium on the machine (it finds Chrome in the usual places; `--browser ` gives another). ```sh npm install -g @farkitect/render ``` Draw a diagram straight from the API with your key: ```sh export FARKITECT_API_KEY=fk_live_… farkitect-render --diagram jh74365kw4gsnrxjk3d5h8pymn8gnt8j -o stakeholders.png --theme dark ``` Or from drawing data your program has already read and saved: ```sh farkitect-render landscape.json -o landscape.png farkitect-render *.json --out-dir pictures --format svg cat landscape.json | farkitect-render - -o landscape.png ``` | Option | Does | |---|---| | `-o, --output ` | The picture's file (one diagram). Its extension sets the format | | `--out-dir ` | Where pictures go when there are several (default: beside each drawing file) | | `--theme light\|dark` | Default `light` | | `--format png\|svg` | Default `png` | | `--scale ` | Pixels per diagram unit, default 2 (as **Share › Export**) | | `--background theme\|transparent` | The theme's canvas colour (default), or none | | `--locale ` | How numbers and dates in values are written, default `en-US` | | `--diagram ` | Fetch this diagram's drawing with `FARKITECT_API_KEY` (repeatable) | | `--api-url ` | Default `https://api.farkitect.com` | | `--browser ` | The Chrome or Chromium to draw with | | `--json` | One line of JSON per picture on standard output: `{ ok, input, output, width, height, ms }` | Several diagrams in one run share one browser, so a batch is much quicker than one run each. The tool exits with 0 when every picture was made, 1 when any failed (each failure is on standard error), and 2 for a usage error. Image shapes are drawn with their pictures when the tool has your key (`FARKITECT_API_KEY`): it fetches each from the shape's `attachment.href`. Without a key they're drawn as their frame. ### From Python ```python import json, os, subprocess, urllib.request API = "https://api.farkitect.com" KEY = os.environ["FARKITECT_API_KEY"] def get(path): request = urllib.request.Request(API + path, headers={"Authorization": f"Bearer {KEY}"}) with urllib.request.urlopen(request) as response: return json.load(response) # Every diagram in a project, drawn in one run. views = get("/v1/projects/PROJECT_ID/views?kind=diagram")["data"] ids = [arg for view in views for arg in ("--diagram", view["id"])] subprocess.run(["farkitect-render", *ids, "--out-dir", "pictures", "--json"], check=True, env={**os.environ, "FARKITECT_API_KEY": KEY}) ``` To redraw only what changed, keep each drawing's `version` and send it back in `If-None-Match`: an unchanged diagram answers **304**, and there's nothing to redraw. ## The drawing package For web pages: one self-contained module, with nothing for your page to provide (it brings its own React and styles, and works with any framework or none). It draws inside a shadow root, so your page's styles never change the diagram and its styles never reach your page. ```sh npm install @farkitect/draw ``` ```js import { drawDiagram, renderDiagram } from "@farkitect/draw"; // Your server reads the drawing data with your key (the API refuses calls from browsers) // and hands it to the page. const drawing = await (await fetch("/my-server/diagrams/landscape")).json(); // On the page: fills the element, which needs a size. const view = drawDiagram(document.getElementById("diagram"), drawing, { theme: "dark", interactive: true, // pan and zoom onSelect: (item) => console.log(item), // a shape, connector or view link clicked }); await view.ready; // Or a picture, without showing anything. const png = await renderDiagram(drawing, { format: "png", scale: 2 }); ``` | `drawDiagram` option | Does | |---|---| | `theme` | `light` (default) or `dark` | | `locale` | How values are written, default `en-US` | | `interactive` | Pan and zoom with the mouse (default off: the diagram fits its box) | | `onSelect(item)` | A shape (`shapeId`, `elementId`), connector (`connectorId`, `relationshipId`) or view link (`linkId`, `target`) was clicked | | `loadImage(href)` | Fetches an image shape's attachment (`/v1/elements/{id}/attachment`) and returns it as a `Blob`. Without one, image shapes draw their frame | The view it returns has `update(drawing)`, `setTheme(theme)`, `fit()`, `toBlob({ format, scale, background })`, `ready` and `destroy()`. `renderDiagram(drawing, options)` takes the same options plus `format`, `scale` and `background`, and gives a `Blob`. Pages without a build step can use the web component: ```html ``` It sends `drawn` when the diagram is drawn, `select` (with the item as `detail`) on a click, and `error`. ## Good to know - **Read-only.** Nothing here changes a model. - **The same as the app.** Shapes, colours in both themes, icons, compartments, labels and connectors are drawn by the code the app draws with, so a picture matches **Share › Export**. - **Fonts.** Text is drawn in the machine's sans-serif font, as the app's is, so a picture made on another machine may differ slightly in its lettering. - **Formats.** This version draws `farkitect-drawing/1` and says so when given another format. - **Licence.** Both are open source under the MIT licence, © Urgnt Limited, so you can use them in your own products, commercial ones included. # Checks Source: https://docs.farkitect.com/api/checks/ `GET /v1/projects/{projectId}/integrity` runs the integrity check. `GET /v1/projects/{projectId}/integrity` runs the same check as the app's Log panel, over every reference in the project's models, metamodels and views. Each finding has a `severity`: - **`error`:** a problem in the model itself, such as an element whose package was deleted. - **`warning`:** a problem in how it's shown or kept, such as a shape on a diagram whose element is gone. `ok` is true when there are no errors; warnings don't count. `checked` says how many of each kind of thing were looked at. It's a heavy call: an organisation may make a few a minute, one at a time ([Rate limits](https://docs.farkitect.com/api/rate-limits/)). ## In CI A step that fails the build when the model has errors (GitHub Actions, with the key in a repository secret): ```yaml - name: Farkitect model integrity env: FARKITECT_API_KEY: ${{ secrets.FARKITECT_API_KEY }} run: | report=$(curl -sf https://api.farkitect.com/v1/projects/PROJECT_ID/integrity \ -H "Authorization: Bearer $FARKITECT_API_KEY") echo "$report" | jq -r '.violations[] | "\(.severity): \(.message) (\(.name // .location // .documentId))"' echo "$report" | jq -e '.ok' > /dev/null ``` # Exports Source: https://docs.farkitect.com/api/exports/ An **export** writes a package and everything below it as a `.farki` file, as **File › Export** does in the app. It runs in the background, so it suits packages too large for [`/contents`](https://docs.farkitect.com/api/models/reading/#a-whole-package-at-once), or keeping a copy of a model. The file can be imported into Farkitect with **File › Import**. | Call | Gives | |---|---| | `POST /v1/packages/{packageId}/exports` | Starts the export, and answers at once with the job (**202**) | | `GET /v1/jobs/{jobId}` | The job's status | | `GET /v1/jobs/{jobId}/file` | The file, once the job is done | ## Why a job? Exporting a large model can take minutes. A single request can't wait that long, so an export works in three steps instead: start it, let it run, then collect the file. That way: - **Nothing times out.** A request to the API is given at most a minute. The export itself runs in the background for as long as it needs, while each request your program makes (start, check, download) is quick. - **A dropped connection loses nothing.** If your program's connection fails while the export runs, the export carries on; check on the job again when you're back. - **The file can be downloaded again.** It's kept for a day, so a download that fails part-way can simply be tried again, without exporting again. - **Everyone stays quick.** Exports are the heaviest work the API does. Running them in the background, one at a time per organisation, keeps one program's export from slowing Farkitect for others. For a package small enough to read in one call, [`/contents`](https://docs.farkitect.com/api/models/reading/#a-whole-package-at-once) is simpler: it answers straight away, as JSON in the API's own shapes. An export gives a `.farki` file, for keeping, moving to another project, or importing again. ## Start, wait, download 1. **Start it.** `POST /v1/packages/{packageId}/exports` answers **202** with the job, and a `Location` header pointing at it. Give a model's own id to export the whole model. 2. **Wait.** Ask `GET /v1/jobs/{jobId}` every few seconds. Its `status` goes `queued`, `running`, then `done`, or `failed` with the reason in `error`. 3. **Download.** When it's `done`, `file` gives the file's name and size, and `GET /v1/jobs/{jobId}/file` returns the file itself, with its name in `Content-Disposition`. Asked for sooner, it answers 409 [`job_not_ready`](https://docs.farkitect.com/api/errors/job-not-ready/). ```python import os, time, requests API = "https://api.farkitect.com/v1" HEADERS = {"Authorization": f"Bearer {os.environ['FARKITECT_API_KEY']}"} def export(package_id, path): job = requests.post(f"{API}/packages/{package_id}/exports", headers=HEADERS) job.raise_for_status() job = job.json() while job["status"] in ("queued", "running"): time.sleep(3) job = requests.get(f"{API}/jobs/{job['id']}", headers=HEADERS).json() if job["status"] != "done": raise RuntimeError(job["error"]) file = requests.get(f"{API}/jobs/{job['id']}/file", headers=HEADERS) file.raise_for_status() with open(path, "wb") as out: out.write(file.content) ``` ## Good to know - **One at a time.** An organisation may have one export running at once. Starting another while one runs gets 429 [`rate_limited`](https://docs.farkitect.com/api/errors/rate-limited/), naming the job that's running: wait for it to finish. - **Kept a day.** A job and its file are deleted a day after it finishes (`expiresAt`). Download the file before then. - **Who can see a job.** Any key of the same organisation that reaches the project; others get 404. - **Not yet:** attachments inside the export (the app's **Export Package with Attachments…**), and whole-project exports. # Rate limits Source: https://docs.farkitect.com/api/rate-limits/ Limits keep one program from crowding out others, and catch a runaway loop before it does harm. They're generous for reports and documents, which need only a handful of requests per run. Limits may be raised over time. ## The limits during early access | What | Allowance | |---|---| | Requests per key, in a burst | 10, refilled at 2 a second (120 a minute) | | Requests per key, running at the same moment | 4 | | Heavy calls (whole packages, the integrity check) per organisation | 6 a minute, 1 at a time, 200 a UTC day | | Changes per key | 30 a minute | | Requests per organisation | 300 a minute, across all its keys | | Requests per organisation per day | 10,000, a UTC day | `GET /v1/me` returns your organisation's current limits in `limits`. ## The headers on every response | Header | What it says | |---|---| | `RateLimit-Limit` | How many requests this key may make **in a burst** (the table above) | | `RateLimit-Remaining` | How many of those are left right now | | `RateLimit-Reset` | Seconds until the next one is back (0 when there are plenty) | Think of a key's allowance as a bucket that holds a burst and refills a few times a second (the first row of the table). A burst goes straight through; after that, requests go through as fast as the bucket refills. A program making one request at a time, waiting for each answer, never notices the limit. **Heavy calls** (a whole package, `/contents` and `/markdown`, and the integrity check) read a lot at once, so an organisation may make only a few, one at a time (the table above). Across all of Farkitect only so many run at once; if it's busy you get 503 [`busy`](https://docs.farkitect.com/api/errors/busy/) with a `Retry-After`. That isn't a limit on you: wait and try again. Separately, a key may have only **a few requests running at the same moment** (the table above). One more sent while those are still being answered gets 429 straight away. Firing many requests in parallel doesn't make a program faster here: send them one after another, or a few at a time. ## When you're limited A limited request gets **429** with the problem code [`rate_limited`](https://docs.farkitect.com/api/errors/rate-limited/) and a `Retry-After` header: the number of seconds to wait. Its `detail` says which limit was reached: ```json { "status": 429, "code": "rate_limited", "detail": "This key may make … requests at once, and … a minute. Wait 1 second and try again. To read a lot at once, the whole-package calls take one request.", "requestId": "req_…" } ``` **What to do:** wait `Retry-After` seconds, then try again. Most HTTP libraries can do this for you (Python's `urllib3.Retry` with `respect_retry_after_header`, for example). If you're limited often, make fewer requests that each do more: ask for up to 200 items a page with `limit`, and, once it arrives, read a whole package in one call. Rate-limited requests are counted under **Too many** in Organisation › Developers › Usage, so you can see if a program is hitting the limit. # Errors Source: https://docs.farkitect.com/api/errors/ Every error from the API has the same shape: an [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) problem, sent as `application/problem+json`, with the HTTP status that suits it. ```json { "type": "https://docs.farkitect.com/api/errors/missing-key", "title": "No API key was given", "status": 401, "detail": "Send your API key in the Authorization header: Authorization: Bearer fk_live_…", "code": "missing_key", "requestId": "req_46075e91719e4bd0a9a4" } ``` | Field | What it is | |---|---| | `code` | What went wrong, as a code. **Branch on this.** Once v1 is declared stable, codes are never renamed or reused. | | `status` | The HTTP status, the same as the response's. | | `title` | A short summary of the kind of problem. | | `detail` | A full sentence about this request: what was wrong and what would be accepted. Written to be shown to a person, or read by an AI assistant fixing its own code. | | `type` | The page here that explains the code. | | `requestId` | This request's id, also in the `Farkitect-Request-Id` header. Quote it when asking for help; it also appears in Organisation › Developers › Failed requests. | | `errors` | Only for `validation_failed`: one entry per field, each with `field` (such as `query.limit`) and `message`. | New codes may be added. If you meet one you don't know, act on its `status`: 4xx means the request needs changing, 429 and 503 mean wait and try again, 500 means try again and tell us if it persists. ## Every code | Code | Status | Meaning | |---|---|---| | [`bad_request`](https://docs.farkitect.com/api/errors/bad-request/) | 400 | The request can't be read | | [`key_in_url`](https://docs.farkitect.com/api/errors/key-in-url/) | 400 | API keys go in the Authorization header, never in the address | | [`invalid_cursor`](https://docs.farkitect.com/api/errors/invalid-cursor/) | 400 | The cursor isn't one this API gave | | [`validation_failed`](https://docs.farkitect.com/api/errors/validation-failed/) | 422 | Some fields aren't valid | | [`idempotency_key_reused`](https://docs.farkitect.com/api/errors/idempotency-key-reused/) | 422 | The Idempotency-Key was used for a different request | | [`missing_key`](https://docs.farkitect.com/api/errors/missing-key/) | 401 | No API key was given | | [`invalid_key`](https://docs.farkitect.com/api/errors/invalid-key/) | 401 | The API key isn't recognised | | [`key_revoked`](https://docs.farkitect.com/api/errors/key-revoked/) | 401 | The API key has been revoked | | [`key_expired`](https://docs.farkitect.com/api/errors/key-expired/) | 401 | The API key has expired | | [`browser_not_allowed`](https://docs.farkitect.com/api/errors/browser-not-allowed/) | 403 | The API can't be called from a web browser | | [`forbidden`](https://docs.farkitect.com/api/errors/forbidden/) | 403 | This key may not do that | | [`organization_suspended`](https://docs.farkitect.com/api/errors/organization-suspended/) | 403 | The organisation can't use the API at present | | [`api_disabled_for_organization`](https://docs.farkitect.com/api/errors/api-disabled-for-organization/) | 403 | The API is switched off for this organisation | | [`plan_required`](https://docs.farkitect.com/api/errors/plan-required/) | 403 | This needs a plan the organisation doesn't have | | [`not_found`](https://docs.farkitect.com/api/errors/not-found/) | 404 | Not found | | [`job_not_ready`](https://docs.farkitect.com/api/errors/job-not-ready/) | 409 | The job hasn't finished yet | | [`resync_required`](https://docs.farkitect.com/api/errors/resync-required/) | 410 | Too long ago: read everything again | | [`precondition_failed`](https://docs.farkitect.com/api/errors/precondition-failed/) | 412 | It has changed since you read it | | [`use_export_job`](https://docs.farkitect.com/api/errors/use-export-job/) | 413 | Too large for one call | | [`too_large`](https://docs.farkitect.com/api/errors/too-large/) | 413 | Too large | | [`rate_limited`](https://docs.farkitect.com/api/errors/rate-limited/) | 429 | Too many requests | | [`quota_exceeded`](https://docs.farkitect.com/api/errors/quota-exceeded/) | 429 | The organisation's allowance is used up | | [`internal_error`](https://docs.farkitect.com/api/errors/internal-error/) | 500 | Something went wrong at Farkitect | | [`api_disabled`](https://docs.farkitect.com/api/errors/api-disabled/) | 503 | The API is switched off for maintenance | | [`unavailable`](https://docs.farkitect.com/api/errors/unavailable/) | 503 | Farkitect can't answer at the moment | | [`busy`](https://docs.farkitect.com/api/errors/busy/) | 503 | Farkitect is busy with other large requests | # Build with an AI assistant Source: https://docs.farkitect.com/api/build-with-ai/ Many programs that use the API will be written with an AI coding assistant (Claude Code, Cursor, Copilot and the like). The API is built to make that go well: one OpenAPI file describes everything, every error says how to fix itself, and there's usually one obvious way to do each thing. ## Give the assistant the API Start your conversation with something like this: ```text I'm writing a program that uses the Farkitect API. - Base address: https://api.farkitect.com/v1 - Its OpenAPI file: https://api.farkitect.com/openapi.json - Its guides, as plain text: https://docs.farkitect.com/llms-full.txt - My API key is in the environment variable FARKITECT_API_KEY. Never put the key in code, logs or a web page. - Errors are RFC 9457 problems: branch on `code`, and show `detail`. - On 429, wait the seconds in Retry-After and try again. - Ignore response fields you don't recognise. Start by calling GET /v1/me to check the key works. ``` Then describe what you want the program to do. `llms.txt` and `llms-full.txt` are the convention AI tools look for: the first is a short index of these docs, the second all the API guides in one plain-text file. ## Web apps: keep the key on a server The API refuses calls from web pages ([`browser_not_allowed`](https://docs.farkitect.com/api/errors/browser-not-allowed/)): a key in a page, or in a browser app's code, can be read by anyone who uses it. So a web app needs a small piece of server code that holds the key and passes calls on. Ask your assistant to use this pattern. A Next.js route, which also works as a Vercel function (`app/api/farkitect/[...path]/route.ts`): ```ts // Passes GET requests on to the Farkitect API, adding the key, which stays // on the server. Only the paths listed here can be reached through it. const ALLOWED = [/^me$/, /^projects(\/.*)?$/]; export async function GET(request: Request, { params }: { params: Promise<{ path: string[] }> }) { // Check your own users here first: anyone who can reach this route can use your key. const path = (await params).path.join("/"); if (!ALLOWED.some((pattern) => pattern.test(path))) { return new Response("Not available", { status: 404 }); } const query = new URL(request.url).search; const response = await fetch(`https://api.farkitect.com/v1/${path}${query}`, { headers: { Authorization: `Bearer ${process.env.FARKITECT_API_KEY}` }, }); return new Response(response.body, { status: response.status, headers: { "Content-Type": response.headers.get("Content-Type") ?? "application/json" }, }); } ``` Your page then calls `/api/farkitect/me` on its own site, and never sees the key. Set `FARKITECT_API_KEY` in the hosting service's environment settings, not in the code. Two things to keep in mind: - **Your route is open to anyone who can reach your site** unless you check your own users first. Keep `ALLOWED` to what the page needs. - **Apps used by other organisations** need each organisation's own consent, not your key. That's what "Sign in with Farkitect" (OAuth) will be for, in a later phase. ## Keys and repositories Quickly written projects are often pushed to a public repository. Keep the key out of every file that's committed: in a `.env` file listed in `.gitignore`, or in the hosting service's settings. If a key is ever committed, revoke it in Organisation › Developers and make a new one; deleting the commit doesn't make it safe again. # API changelog Source: https://docs.farkitect.com/api/changelog/ Every change to the API, newest first. **v1 is a preview** until it is declared stable: most changes are **additions** (new endpoints, fields, error codes or values), which a program that ignores what it doesn't recognise keeps working through, but a change may also be **Breaking**, and is then marked so. See [Versions](https://docs.farkitect.com/api/overview/#versions). Changes to the rest of Farkitect are in [What's New](https://docs.farkitect.com/getting-started/whats-new/). ## Release 384: views' permanent ids in events *An addition.* - An [event](https://docs.farkitect.com/api/events/) about a diagram, catalog, board or chart view now has the view's permanent id in `item.uid`, in webhook deliveries too. It was null for views; events recorded earlier keep null. ## Release 383: included models, and views' permanent ids *Additions.* - A package has `included`: on a model (a top-level package) included from another project of the organisation, the project it comes from, the project that defines it, the version it holds and its state; null otherwise. In every package the API returns. See [Included metamodels](https://docs.farkitect.com/api/metamodels/#included-metamodels), which models follow. - Writes to an included model, or to anything in it, are refused with `403 forbidden`, saying to change it in the project it comes from. Relationships from the project's own elements to its elements are allowed, as in the app. - A view has `uid`, its permanent id, and `originUid` (on an included model's view, the original's). In `GET /v1/projects/{projectId}/views` and `GET /v1/diagrams/{diagramId}`. - `originUid` on packages, elements and relationships is now set on an included model's items: the original's `uid`. ## Release 379: integrity messages for values *No change to any field.* - In `GET /v1/projects/{projectId}/integrity`, a `value-does-not-fit` violation's `message` now says what is wrong with that value (for example, a date and time with no time zone), instead of the general explanation every such violation had. ## Release 377: included metamodels *Additions.* - A metamodel has `included`: for one included from another project, the project it comes from, the project that defines it, the version it holds and its state; null for the project's own. In `GET /v1/projects/{projectId}/metamodels` and `GET /v1/metamodels/{metamodelId}`. See [Included metamodels](https://docs.farkitect.com/api/metamodels/#included-metamodels). ## Release 374: relationships between models *Additions; one rule loosened.* - A relationship may now join elements of **two models** of a project. `POST …/relationships` and `PATCH` with `sourceId` or `targetId` no longer refuse that; the type must be from a metamodel that **both ends' models** import. Where it's kept follows the app: in the source's package, or in `packageId` when that is in the source's model. - Each end of a relationship (`source`, `target`) has a `model`: the model it is in, by `id` and `name`. In every relationship the API returns: lists, single reads, writes, a package's contents, and events and webhook deliveries with the item. - A move no longer refuses to leave a relationship between two models; a relationship whose ends both leave its model moves with its source, as in the app. ## Release 370: permanent ids *Additions.* - Every package, element and relationship has a `uid`, its permanent id, which never changes: a Restore Project, a Replace or FarkiBot's Modify can change an item's `id`, never its `uid`. Store the `uid` to find an item again later. Also `originUid`, null for now. See [Ids and permanent ids](https://docs.farkitect.com/api/ids/). - `?uid=` on `GET /v1/projects/{projectId}/elements`, `…/packages` and `…/relationships`: the item with that permanent id, whatever its `id` is now. - An [event](https://docs.farkitect.com/api/events/)'s `item` has a `uid` beside its `id` (null for a view), in webhook deliveries too. ## Release 363: webhooks *Additions.* - `POST /v1/webhook-endpoints` and its calls: have each [event](https://docs.farkitect.com/api/events/) posted to your own address as it happens, signed in the Standard Webhooks format, retried for about a day and a half, with a delivery log, pings, retries and secret rotation. Managed with a whole-organisation key that may manage the organisation's webhooks. See [Webhooks](https://docs.farkitect.com/api/webhooks/). ## Release 362: events *Additions.* - `GET /v1/projects/{projectId}/events`: every change to a project's packages, elements, relationships and views, oldest first, however it was made, with what changed and who made it; kept 30 days, recorded while the organisation has a working key. Filter by `types`; `include=item` adds each item as it is now. Its cursor is always given, so a program up to date keeps it and asks again later. See [Events](https://docs.farkitect.com/api/events/). ## Release 361: tidied before others build on it *One addition; one removal (**Breaking**, for a program that reads it).* - An element type's new `attachment` says what its elements may have attached: `image`, `file`, or null. See [What an element can have attached](https://docs.farkitect.com/api/metamodels/#what-an-element-can-have-attached). - **Breaking:** the key's `limits` (`GET /v1/me`) no longer include `imagesPerMinutePerOrganization` and `imagesAtOnce`. They were for drawing diagram images on the server, which was set aside; [drawing data](https://docs.farkitect.com/api/drawing/) took its place. - The docs now say to match an element's values on `propertyTypeId` rather than its name, which can change ([Reading models](https://docs.farkitect.com/api/models/reading/)). ## Release 359: attaching files *Additions.* - `PUT /v1/elements/{elementId}/attachment`: attach a file to an element (the file as the body, up to 4 MB), replacing any it had; `DELETE /v1/elements/{elementId}/attachment` removes it. The same rules as the app: only an element whose type allows an attachment, images only for an image type. See [Attaching files](https://docs.farkitect.com/api/models/changing/#attaching-files). - An element's `updatedAt` and `ETag` now also change when its attachment is set or removed, in the app too. - [`too_large`](https://docs.farkitect.com/api/errors/too-large/) (413) now also comes from a file over 4 MB. ## Release 351: deletions, and large deletes *Additions, and one change.* - `GET /v1/projects/{projectId}/deletions?since=…`: every package, element, relationship and view deleted since a time, however it was deleted, remembered 30 days. See [Keeping another system in step](https://docs.farkitect.com/api/models/reading/#keeping-another-system-in-step). - A delete of more than 200 elements and relationships answers `202` with a job (`kind: "delete"`) that deletes them in the background. Jobs gain `deleted`, the count when a delete is done. - New error code [`resync_required`](https://docs.farkitect.com/api/errors/resync-required/) (410). - **Changed:** a large single delete was refused with `413 too_large`; it now runs as a job. `too_large` now comes only from a batch. ## Release 350: relationships, and many changes at once *Additions.* - `POST /v1/projects/{projectId}/relationships`, `PATCH` and `DELETE /v1/relationships/{relationshipId}`: a relationship by type id or name, between two elements of one model, refused when its type can't join that pair. See [Changing models](https://docs.farkitect.com/api/models/changing/#relationships). - `POST /v1/projects/{projectId}/batch`: up to 200 creates, updates and deletes, all or none, with `ref`s for items made earlier in the batch. See [Many changes at once](https://docs.farkitect.com/api/models/changing/#many-changes-at-once). - `ETag` on every relationship write, as for packages and elements. ## Release 349: changing models *Additions.* - [Changing models](https://docs.farkitect.com/api/models/changing/): `POST /v1/projects/{projectId}/packages`, `PATCH` and `DELETE /v1/packages/{packageId}`, `POST /v1/projects/{projectId}/elements`, `PATCH` and `DELETE /v1/elements/{elementId}`. Values are written in their natural types, by property type name or id; an element's type by id or by name. Needs a contributor or admin key. - `GET /v1/packages/{packageId}`: one package. - `ETag` on one package, element or relationship, and on every change's answer; `If-Match` on a change or a delete. - `Idempotency-Key` on every change: a repeat within a day gives the first answer. - New error codes: [`precondition_failed`](https://docs.farkitect.com/api/errors/precondition-failed/) (412), [`idempotency_key_reused`](https://docs.farkitect.com/api/errors/idempotency-key-reused/) (422), [`too_large`](https://docs.farkitect.com/api/errors/too-large/) (413). `validation_failed` now also comes from Farkitect's own rules, with `errors` naming each field. ## Release 348: the drawing package and tool are on npm *No change to the API.* - `@farkitect/draw` and `@farkitect/render` (the `farkitect-render` tool) are published on npm, so the commands in [Drawing a diagram in your program](https://docs.farkitect.com/api/drawing/) now work as written. ## Release 347: drawing diagrams in your program *Additions (outside the API itself).* - [Drawing a diagram in your program](https://docs.farkitect.com/api/drawing/): Farkitect's drawing package, `@farkitect/draw`, draws a diagram's drawing data in a web page exactly as the app does, and the command-line tool `farkitect-render` makes PNG or SVG pictures of it from any language. Both are about to be published to npm. ## Release 346: v1 is a preview; more drawing data *Additions, and a change to how v1 changes.* - **v1 is a preview** until it is declared stable: until then a change may break a working program, and every such change is marked **Breaking** here. Most changes remain additions. See [Versions](https://docs.farkitect.com/api/overview/#versions). - `GET /v1/diagrams/{diagramId}/drawing`: each type gains `ownColours`, the colours its notation sets (`null` where Auto), from which its `colours` are worked out; each value gains `text`, the value exactly as stored. ## Release 345: drawing data for shapes that don't fit their metamodel *An addition and a correction.* - Shapes and connectors in `GET /v1/diagrams/{diagramId}/drawing` gain `opacity`: 0.4 for one that doesn't fit its metamodel, else 1. - Corrected: the colours of a shape or connector that doesn't fit its metamodel were its usual ones; they are now the theme's muted colours the app draws it in. See [Views](https://docs.farkitect.com/api/views/#drawing-a-diagram). ## Release 344: a diagram's drawing data *Additions.* - `GET /v1/diagrams/{diagramId}/drawing`: everything a diagram shows, to draw it as the app does: final colours in both themes, the types used and their icons once each, values, labels, nesting, view links. Its `version` is the `ETag`; `If-None-Match` answers 304 when nothing changed. See [Views](https://docs.farkitect.com/api/views/#drawing-a-diagram). ## Release 339: export jobs *Additions.* - `POST /v1/packages/{packageId}/exports` (202, a job), `GET /v1/jobs/{jobId}` and `GET /v1/jobs/{jobId}/file`: a package exported as `.farki` in the background, kept a day. One at a time per organisation. See [Exports](https://docs.farkitect.com/api/exports/). - A new error code, [`job_not_ready`](https://docs.farkitect.com/api/errors/job-not-ready/) (409). ## Release 338: views and the integrity check *Additions.* - `GET /v1/projects/{projectId}/views` (`kind`, `packageId`): every diagram, catalog, board and chart view, with a catalog's or board's type, a board's group-by and a view's scope. Catalog rows and board cards aren't given yet. - `GET /v1/diagrams/{diagramId}`: a diagram's shapes, connectors (with bend points) and links to other views. - `GET /v1/projects/{projectId}/integrity`: the integrity check, with `ok`, `errors` and `warnings`, for CI. A heavy call. See [Views](https://docs.farkitect.com/api/views/) and [Checks](https://docs.farkitect.com/api/checks/). ## Release 336: whole packages *Additions.* - `GET /v1/packages/{packageId}/contents` (`include=metamodel`) and `GET /v1/packages/{packageId}/markdown`: a whole package in one call. See [Reading models](https://docs.farkitect.com/api/models/reading/#a-whole-package-at-once). - Heavy-call limits: 6 a minute, 1 at a time and 200 a day per organisation (`limits.heavy…` in `GET /v1/me`). See [Rate limits](https://docs.farkitect.com/api/rate-limits/). - New error codes [`use_export_job`](https://docs.farkitect.com/api/errors/use-export-job/) (413) and [`busy`](https://docs.farkitect.com/api/errors/busy/) (503). ## Release 335: models *Additions.* - `GET /v1/projects/{projectId}/packages`, `…/elements` and `…/relationships`, with filters (`type`, `packageId`, `sourceId`, `targetId`, `elementId`) and `include=properties`; `GET /v1/elements/{elementId}` and `GET /v1/relationships/{relationshipId}`. See [Reading models](https://docs.farkitect.com/api/models/reading/). - Property values in their natural JSON types, with `fits` and, for enumerations, `storedValue`. - `updatedSince` on elements and relationships, oldest change first, for keeping another system in step. Every change to an element's values now counts as a change to the element. - `GET /v1/elements/{elementId}/attachment`: the attached file itself. ## Release 334: projects and metamodels *Additions.* - `GET /v1/projects` and `GET /v1/projects/{projectId}`: the projects a key reaches. - `GET /v1/projects/{projectId}/metamodels`, `GET /v1/metamodels/{metamodelId}`, and its `element-types`, `relationship-types` and `enumerations`: what a project's models are made of, with property types own and inherited. See [Projects](https://docs.farkitect.com/api/projects/) and [Metamodels](https://docs.farkitect.com/api/metamodels/). - Lists: `{ object, data, hasMore, nextCursor }`, with `limit` and `cursor`. A page can hold fewer than `limit`. - A new error code, [`invalid_cursor`](https://docs.farkitect.com/api/errors/invalid-cursor/) (400), and [`api_disabled_for_organization`](https://docs.farkitect.com/api/errors/api-disabled-for-organization/) (403). - A new limit: 4 requests running at once per key (`limits.requestsAtOncePerKey` in `GET /v1/me`). See [Rate limits](https://docs.farkitect.com/api/rate-limits/). ## 5 November 2026: v1, early access *Additions.* The API opens in early access, free for every organisation. - `GET /v1/me`: the calling key, its organisation, the projects it reaches with its role in each, its expiry and the organisation's limits. - API keys in Organisation › Developers: whole organisation or one project; viewer, contributor or admin; expiring, extendable, revocable. A project's Members tab lists the keys that reach it. - Errors as RFC 9457 problems with stable codes ([Errors](https://docs.farkitect.com/api/errors/)); rate limits with `RateLimit-*` headers ([Rate limits](https://docs.farkitect.com/api/rate-limits/)). - The interactive reference at [api.farkitect.com/docs](https://api.farkitect.com/docs), the OpenAPI file, and `llms.txt` / `llms-full.txt`. # api_disabled Source: https://docs.farkitect.com/api/errors/api-disabled/ **503** · The API is switched off for maintenance. ## What it means The API is switched off for maintenance. ## How to put it right Try again later. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/api-disabled", "title": "The API is switched off for maintenance", "status": 503, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "api_disabled", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # api_disabled_for_organization Source: https://docs.farkitect.com/api/errors/api-disabled-for-organization/ **403** · The API is switched off for this organisation. ## What it means Farkitect has switched the API off for the key's organisation, for now. The organisation's keys are kept and work again once it is switched back on. ## How to put it right Contact Farkitect support, quoting the request id. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/api-disabled-for-organization", "title": "The API is switched off for this organisation", "status": 403, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "api_disabled_for_organization", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # bad_request Source: https://docs.farkitect.com/api/errors/bad-request/ **400** · The request can't be read. ## What it means The request couldn't be read: the body isn't valid JSON, or something about the request's form is wrong. ## How to put it right Send JSON with `Content-Type: application/json`, and check the request against the [API reference](https://api.farkitect.com/docs). ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/bad-request", "title": "The request can't be read", "status": 400, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "bad_request", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # browser_not_allowed Source: https://docs.farkitect.com/api/errors/browser-not-allowed/ **403** · The API can't be called from a web browser. ## What it means The request came from a web page (it had an `Origin` header from another site, or was a CORS preflight). The API refuses these because a key in a web page can be read by anyone using the page. ## How to put it right Call the API from a server instead: a script, a backend, or a small serverless function that holds the key and passes calls on. See [Build with an AI assistant](https://docs.farkitect.com/api/build-with-ai/) for a template. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/browser-not-allowed", "title": "The API can't be called from a web browser", "status": 403, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "browser_not_allowed", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # busy Source: https://docs.farkitect.com/api/errors/busy/ **503** · Farkitect is busy with other large requests. ## What it means Too many large requests (whole packages at once) are running across Farkitect right now, so this one wasn't started. It isn't a limit on your organisation. ## How to put it right Wait the seconds in `Retry-After` and try again. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/busy", "title": "Farkitect is busy with other large requests", "status": 503, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "busy", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # forbidden Source: https://docs.farkitect.com/api/errors/forbidden/ **403** · This key may not do that. ## What it means The key may not do this: its role doesn't allow it (a viewer changing a model, say), or the request needs a permission the key wasn't given. ## How to put it right Use a key with the role it needs, or ask for one. Keys are given the least they need; see [API keys](https://docs.farkitect.com/api/keys/). ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/forbidden", "title": "This key may not do that", "status": 403, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "forbidden", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # idempotency_key_reused Source: https://docs.farkitect.com/api/errors/idempotency-key-reused/ **422** · The Idempotency-Key was used for a different request. ## What it means The `Idempotency-Key` sent was already used, within the last day, with a different request (another path, or another body). A key stands for one change: repeating it returns that change's answer, so it can't be used for another. ## How to put it right Make a new key for each change (a random UUID is usual), and reuse a key only to retry exactly the same request after a failure or a timeout. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/idempotency-key-reused", "title": "The Idempotency-Key was used for a different request", "status": 422, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "idempotency_key_reused", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # internal_error Source: https://docs.farkitect.com/api/errors/internal-error/ **500** · Something went wrong at Farkitect. ## What it means Something went wrong at Farkitect. It isn't your request's fault. ## How to put it right Try again in a moment. If it keeps happening, contact Farkitect support and quote the request id. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/internal-error", "title": "Something went wrong at Farkitect", "status": 500, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "internal_error", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # invalid_cursor Source: https://docs.farkitect.com/api/errors/invalid-cursor/ **400** · The cursor isn't one this API gave. ## What it means The `cursor` sent isn't a `nextCursor` from this API: it was changed, cut short, taken from another list or another environment, or is from an older version of the list. ## How to put it right Pass `nextCursor` from the previous page exactly as it came, to the same list with the same filters. To start again, leave `cursor` out. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/invalid-cursor", "title": "The cursor isn't one this API gave", "status": 400, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "invalid_cursor", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # invalid_key Source: https://docs.farkitect.com/api/errors/invalid-key/ **401** · The API key isn't recognised. ## What it means The key isn't recognised. Either it isn't shaped like a Farkitect key (`fk_live_` or `fk_test_` and 40 letters and digits), or no such key exists here. ## How to put it right Check the key was copied whole, with no spaces or quotes. A `fk_live_` key works at `api.farkitect.com`; a `fk_test_` key only on a test deployment. If the key is lost, make a new one: keys can't be shown again. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/invalid-key", "title": "The API key isn't recognised", "status": 401, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "invalid_key", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # job_not_ready Source: https://docs.farkitect.com/api/errors/job-not-ready/ **409** · The job hasn't finished yet. ## What it means The job's file was asked for before the job finished: it's still `queued` or `running`. ## How to put it right Ask `GET /v1/jobs/{jobId}` every few seconds until `status` is `done`, then download the file. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/job-not-ready", "title": "The job hasn't finished yet", "status": 409, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "job_not_ready", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # key_expired Source: https://docs.farkitect.com/api/errors/key-expired/ **401** · The API key has expired. ## What it means The key has passed its expiry date. Every key expires, after 30 days to a year as chosen when it was made; a week before, whoever manages it is emailed. ## How to put it right Ask one of the organisation's owners or admins (or the project's admins, for a one-project key) to **Extend** it in Organisation › Developers. It stays the same key, so nothing needs changing in your program. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/key-expired", "title": "The API key has expired", "status": 401, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "key_expired", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # key_in_url Source: https://docs.farkitect.com/api/errors/key-in-url/ **400** · API keys go in the Authorization header, never in the address. ## What it means An API key was found in the address (the URL or its query string). Addresses end up in logs, browser history and analytics, so a key there is treated as leaked. ## How to put it right Send the key only in the `Authorization` header: `Authorization: Bearer fk_live_…`. Then revoke the key that was in the address and make a new one in Organisation › Developers. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/key-in-url", "title": "API keys go in the Authorization header, never in the address", "status": 400, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "key_in_url", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # key_revoked Source: https://docs.farkitect.com/api/errors/key-revoked/ **401** · The API key has been revoked. ## What it means The key was revoked, so it no longer works. Revoking is immediate and can't be undone. ## How to put it right Ask one of the organisation's owners or admins (or, for a one-project key, the project's admins) for a new key, and replace the old one wherever it's used. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/key-revoked", "title": "The API key has been revoked", "status": 401, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "key_revoked", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # missing_key Source: https://docs.farkitect.com/api/errors/missing-key/ **401** · No API key was given. ## What it means The request had no API key: no `Authorization` header, or `Bearer` with nothing after it. ## How to put it right Add the header `Authorization: Bearer `. Keys are made in the website's Organisation › Developers; keep yours in an environment variable such as `FARKITECT_API_KEY`. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/missing-key", "title": "No API key was given", "status": 401, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "missing_key", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # not_found Source: https://docs.farkitect.com/api/errors/not-found/ **404** · Not found. ## What it means There's nothing at that address, or nothing this key can see there. Ids from other organisations, or projects the key doesn't reach, also give this, so ids can't be probed. ## How to put it right Check the path against the [API reference](https://api.farkitect.com/docs), and that the id belongs to a project the key reaches (`GET /v1/me` lists them). ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/not-found", "title": "Not found", "status": 404, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "not_found", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # organization_suspended Source: https://docs.farkitect.com/api/errors/organization-suspended/ **403** · The organisation can't use the API at present. ## What it means The key's organisation can't use the API at present. ## How to put it right Contact Farkitect support, quoting the request id. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/organization-suspended", "title": "The organisation can't use the API at present", "status": 403, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "organization_suspended", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # plan_required Source: https://docs.farkitect.com/api/errors/plan-required/ **403** · This needs a plan the organisation doesn't have. ## What it means This needs something the organisation's plan doesn't include. During early access every organisation has the same free plan, so this isn't returned yet. ## How to put it right When plans exist, an organisation's owners will be able to change plan. Until then, contact Farkitect support. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/plan-required", "title": "This needs a plan the organisation doesn't have", "status": 403, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "plan_required", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # precondition_failed Source: https://docs.farkitect.com/api/errors/precondition-failed/ **412** · It has changed since you read it. ## What it means The request had an `If-Match` header, and the item has changed since that version: someone, or another program, edited it after you read it. Nothing was changed. ## How to put it right Read the item again (its `ETag` header is the new version), apply your change to what is there now, and send it with the new `ETag` in `If-Match`. Leave `If-Match` out only if overwriting others' changes is what you want. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/precondition-failed", "title": "It has changed since you read it", "status": 412, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "precondition_failed", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # quota_exceeded Source: https://docs.farkitect.com/api/errors/quota-exceeded/ **429** · The organisation's allowance is used up. ## What it means The organisation has used its allowance for the period. During early access there are no such allowances, so this isn't returned yet. ## How to put it right Wait for the next period, or contact Farkitect support. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/quota-exceeded", "title": "The organisation's allowance is used up", "status": 429, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "quota_exceeded", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # rate_limited Source: https://docs.farkitect.com/api/errors/rate-limited/ **429** · Too many requests. ## What it means Too many requests: the key's, or its organisation's, allowance is used up for now. The `detail` says which limit, and `Retry-After` how many seconds to wait. ## How to put it right Wait `Retry-After` seconds and try again; slow down, or make fewer requests that each do more. See [Rate limits](https://docs.farkitect.com/api/rate-limits/). ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/rate-limited", "title": "Too many requests", "status": 429, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "rate_limited", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # resync_required Source: https://docs.farkitect.com/api/errors/resync-required/ **410** · Too long ago: read everything again. ## What it means Deletions are remembered for 30 days, and `since` is further back than that, so some deletions since then are no longer known. ## How to put it right Read the project's models again in full (the lists, or `/contents` for a package), note the time you started, and from then on follow `GET /v1/projects/{projectId}/deletions` with `since` at most 30 days back. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/resync-required", "title": "Too long ago: read everything again", "status": 410, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "resync_required", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # too_large Source: https://docs.farkitect.com/api/errors/too-large/ **413** · Too large. ## What it means The request is larger than one call can take: a file sent as an attachment is over 4 MB, or a delete in a batch would take more than 200 elements and relationships with it (a batch is one step, all or none, so its deletes must be small). ## How to put it right For an attachment, send a smaller file (compress an image, or split a document); larger files can be attached in the app. For a batch, send that delete on its own (`DELETE /v1/packages/{packageId}` or `/v1/elements/{elementId}`): a large one answers 202 with a job that deletes it in the background. Or delete what's inside it in smaller parts. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/too-large", "title": "Too large", "status": 413, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "too_large", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # unavailable Source: https://docs.farkitect.com/api/errors/unavailable/ **503** · Farkitect can't answer at the moment. ## What it means Farkitect couldn't answer at the moment, usually because its database couldn't be reached. ## How to put it right Try again in a few seconds, waiting longer each time. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/unavailable", "title": "Farkitect can't answer at the moment", "status": 503, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "unavailable", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # use_export_job Source: https://docs.farkitect.com/api/errors/use-export-job/ **413** · Too large for one call. ## What it means The package is too large to give in one call: its contents would be over 10 MB, or take more than 45 seconds to gather. ## How to put it right Export it instead: `POST /v1/packages/{packageId}/exports` starts a `.farki` export in the background (see [Export jobs](https://docs.farkitect.com/api/exports/)). Or read it a page at a time: `GET /v1/projects/{projectId}/elements` and `/relationships` with `packageId` give one package's items. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/use-export-job", "title": "Too large for one call", "status": 413, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "use_export_job", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped. # validation_failed Source: https://docs.farkitect.com/api/errors/validation-failed/ **422** · Some fields aren't valid. ## What it means The request was read, but one or more fields aren't valid. The problem's `errors` list names each field (such as `query.limit`) and what's wrong with it. ## How to put it right Correct each field listed in `errors` and send the request again. ## What the response looks like ```json { "type": "https://docs.farkitect.com/api/errors/validation-failed", "title": "Some fields aren't valid", "status": 422, "detail": "A sentence about this request: what was wrong, and what would be accepted.", "code": "validation_failed", "requestId": "req_46075e91719e4bd0a9a4" } ``` Branch on `code`, not on `title` or `detail`, which may be reworded. See [Errors](https://docs.farkitect.com/api/errors/) for how every error is shaped.