{
  "opencollection": "1.0.0",
  "info": {
    "name": "Primitive Account Functions API",
    "version": "1.0.0"
  },
  "items": [
    {
      "info": {
        "name": "Functions",
        "type": "folder"
      },
      "items": [
        {
          "info": {
            "name": "List functions",
            "type": "http"
          },
          "http": {
            "method": "GET",
            "url": "https://api.primitive.dev/v1/functions",
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Returns every active (non-deleted) function in the org, newest\nfirst. Each entry carries deploy status and timestamps. To\ninspect the source code or deploy errors, use `GET /functions/{id}`.\n"
        },
        {
          "info": {
            "name": "Deploy a function",
            "type": "http"
          },
          "http": {
            "method": "POST",
            "url": "https://api.primitive.dev/v1/functions",
            "headers": [
              {
                "name": "Idempotency-Key",
                "value": ""
              }
            ],
            "body": {
              "type": "json",
              "data": "{}"
            },
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Creates and deploys a new function. The handler must be a single\nESM module whose default export is an object with an async\n`fetch(request, env)` method (Workers-style). Primitive signs\neach delivery and forwards the `Primitive-Signature` header to\nthe handler. Verify the raw request body with\n`PRIMITIVE_WEBHOOK_SECRET` before parsing JSON; after verification\nthe request body parses to a webhook event whose `event` field is\n`email.received` for normal inbound mail, or a machine-mail type\n(`email"
        },
        {
          "info": {
            "name": "Get a function",
            "type": "http"
          },
          "http": {
            "method": "GET",
            "url": "https://api.primitive.dev/v1/functions/:id",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              }
            ],
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Returns the full record for a function, including its current\nsource code and the deploy status / error from the most recent\ndeploy attempt.\n"
        },
        {
          "info": {
            "name": "Update and redeploy a function",
            "type": "http"
          },
          "http": {
            "method": "PUT",
            "url": "https://api.primitive.dev/v1/functions/:id",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              }
            ],
            "body": {
              "type": "json",
              "data": "{}"
            },
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Replaces the function's source code with the body's `code` and\ntriggers a redeploy. Same size limits as `POST /functions`.\nUse this verb to push secret writes into the running handler:\npassing the same `code` re-runs the deploy and refreshes the\nbinding set with the latest values from the secrets table.\n\nOn deploy failure, the previously-deployed code stays live; the\nruntime never serves a half-built bundle. The response uses\n`error.code` `deploy_failed`, and the function's `deploy_error`\nfield "
        },
        {
          "info": {
            "name": "Delete a function",
            "type": "http"
          },
          "http": {
            "method": "DELETE",
            "url": "https://api.primitive.dev/v1/functions/:id",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              }
            ],
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Delete a hosted inbound function. It stops running on future inbound messages."
        },
        {
          "info": {
            "name": "Send a test invocation",
            "type": "http"
          },
          "http": {
            "method": "POST",
            "url": "https://api.primitive.dev/v1/functions/:id/test",
            "headers": [
              {
                "name": "Idempotency-Key",
                "value": ""
              }
            ],
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              }
            ],
            "body": {
              "type": "json",
              "data": "{}"
            },
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Sends a real test email from a Primitive-controlled sender to a\nlocal-part on one of the org's verified inbound domains. By\ndefault the recipient is a synthetic\n`__primitive_function_test+<random>@<domain>` address on a\ndomain selected to route to the function. Scoped functions use\ntheir scoped domain; fallback functions use a domain that has\nno enabled domain-scoped endpoint. Pass `local_part` to\noverride and exercise routing logic that branches on a specific\nrecipient (the common pattern when "
        },
        {
          "info": {
            "name": "Get a function test run trace",
            "type": "http"
          },
          "http": {
            "method": "GET",
            "url": "https://api.primitive.dev/v1/functions/:id/test-runs/:run_id/trace",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              },
              {
                "name": "run_id",
                "value": "",
                "type": "path",
                "description": "Function test run id returned by POST /functions/{id}/test."
              }
            ],
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Returns the current end-to-end trace for a function test run.\nThe trace is intentionally partial while the test is still in\nflight: callers can poll this endpoint and watch it fill in\nfrom send -> inbound -> webhook deliveries -> outbound\nrequests, logs, and replies.\n"
        },
        {
          "info": {
            "name": "Get the org's function routing topology",
            "type": "http"
          },
          "http": {
            "method": "GET",
            "url": "https://api.primitive.dev/v1/functions/routing-topology",
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Returns a single snapshot of how inbound mail is routed across\nthis org's active domains and functions: which active domain has\nwhich function bound, the org's fallback function (if any), and\nevery deployed function with no route bound. Use this to answer\n\"which of my functions actually receive mail?\" diagnostically.\n"
        },
        {
          "info": {
            "name": "Get a function's current route binding",
            "type": "http"
          },
          "http": {
            "method": "GET",
            "url": "https://api.primitive.dev/v1/functions/:id/routing",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              }
            ],
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Returns the endpoint binding for the function, or null when no\nroute is currently bound. The binding identifies whether the\nfunction receives mail for a specific domain (scoped) or for any\nactive domain that has no scoped binding (fallback).\n"
        },
        {
          "info": {
            "name": "Bind a route to a function",
            "type": "http"
          },
          "http": {
            "method": "PUT",
            "url": "https://api.primitive.dev/v1/functions/:id/route",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              }
            ],
            "body": {
              "type": "json",
              "data": "{}"
            },
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Binds inbound mail to this function. The route target is either\na specific verified domain (scoped) or the org's fallback (any\nactive domain with no scoped binding). If another function is\nalready bound at the target, returns a `conflict` envelope\ndescribing the holder; re-issue with `takeover: true` to\ndeactivate that prior binding and install this one.\n"
        },
        {
          "info": {
            "name": "Unbind any route from a function",
            "type": "http"
          },
          "http": {
            "method": "DELETE",
            "url": "https://api.primitive.dev/v1/functions/:id/route",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              }
            ],
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Deactivates every active endpoint bound to this function. The\nfunction stays deployed but stops receiving inbound mail. Safe\nto call when no route is currently bound (no-op).\n"
        },
        {
          "info": {
            "name": "List a function's secrets",
            "type": "http"
          },
          "http": {
            "method": "GET",
            "url": "https://api.primitive.dev/v1/functions/:id/secrets",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              }
            ],
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Returns metadata for every secret bound to the function, with\nmanaged entries (provisioned by Primitive) listed first and\nuser-set entries listed alphabetically after. **Values are\nnever returned.** Secret writes are write-only.\n\nManaged entries (e.g. `PRIMITIVE_WEBHOOK_SECRET`,\n`PRIMITIVE_API_KEY`, `PRIMITIVE_API_BASE_URL`) carry a\n`description` instead of `created_at` / `updated_at`. They\ncannot be created, updated, or deleted via this API.\n"
        },
        {
          "info": {
            "name": "Create or update a secret",
            "type": "http"
          },
          "http": {
            "method": "POST",
            "url": "https://api.primitive.dev/v1/functions/:id/secrets",
            "headers": [
              {
                "name": "Idempotency-Key",
                "value": ""
              }
            ],
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              }
            ],
            "body": {
              "type": "json",
              "data": "{}"
            },
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Idempotent insert-or-update keyed on `(function_id, key)`.\nReturns 201 the first time the key is set, 200 on subsequent\nupdates. Values are encrypted at rest and only become visible\nto the running handler on the next deploy (`PUT /functions/{id}`\nwith the existing code is sufficient to refresh bindings).\n\nKeys must match `^[A-Z_][A-Z0-9_]*$` (uppercase letters,\ndigits, underscores; first character is a letter or\nunderscore). Values are at most 4096 UTF-8 bytes. System-\nmanaged keys are reserved "
        },
        {
          "info": {
            "name": "Set a secret by key",
            "type": "http"
          },
          "http": {
            "method": "PUT",
            "url": "https://api.primitive.dev/v1/functions/:id/secrets/:key",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              },
              {
                "name": "key",
                "value": "",
                "type": "path",
                "description": "Secret key. Must match `^[A-Z_][A-Z0-9_]*$`."
              }
            ],
            "body": {
              "type": "json",
              "data": "{}"
            },
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Path-keyed companion to `POST /functions/{id}/secrets`.\nIdempotent: returns 201 the first time the key is set, 200 on\nsubsequent updates. Same validation rules and same write-only\nguarantees as the POST verb; the new value lands in the running\nhandler on the next deploy.\n"
        },
        {
          "info": {
            "name": "Delete a secret",
            "type": "http"
          },
          "http": {
            "method": "DELETE",
            "url": "https://api.primitive.dev/v1/functions/:id/secrets/:key",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              },
              {
                "name": "key",
                "value": "",
                "type": "path",
                "description": "Secret key. Must match `^[A-Z_][A-Z0-9_]*$`."
              }
            ],
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Removes the secret. The binding stays live in the running\nhandler until the next deploy refreshes the binding set\n(`PUT /functions/{id}` with the existing code is sufficient).\nReturns 404 if the key did not exist. Managed system keys\ncannot be deleted.\n"
        },
        {
          "info": {
            "name": "List org-level (global) secrets",
            "type": "http"
          },
          "http": {
            "method": "GET",
            "url": "https://api.primitive.dev/v1/org/secrets",
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Returns metadata for every org-level secret. Org secrets apply\nto every function in the org and are read as `env.<KEY>` in\nhandlers. **Values are never returned.** Secret writes are\nwrite-only. A function-level secret of the same name overrides\nthe org-level value for that function.\n"
        },
        {
          "info": {
            "name": "Create or update an org secret",
            "type": "http"
          },
          "http": {
            "method": "POST",
            "url": "https://api.primitive.dev/v1/org/secrets",
            "headers": [
              {
                "name": "Idempotency-Key",
                "value": ""
              }
            ],
            "body": {
              "type": "json",
              "data": "{}"
            },
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Idempotent insert-or-update keyed on `(org_id, key)`. Returns\n201 the first time the key is set, 200 on subsequent updates.\nValues are encrypted at rest. A changed value lands in a\nfunction only on that function's next deploy.\n\nKeys must match `^[A-Z_][A-Z0-9_]*$` (uppercase letters,\ndigits, underscores; first character is a letter or\nunderscore). Values are at most 4096 UTF-8 bytes. System-\nmanaged keys are reserved and rejected.\n"
        },
        {
          "info": {
            "name": "Set an org secret by key",
            "type": "http"
          },
          "http": {
            "method": "PUT",
            "url": "https://api.primitive.dev/v1/org/secrets/:key",
            "params": [
              {
                "name": "key",
                "value": "",
                "type": "path",
                "description": "Secret key. Must match `^[A-Z_][A-Z0-9_]*$`."
              }
            ],
            "body": {
              "type": "json",
              "data": "{}"
            },
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Path-keyed companion to `POST /org/secrets`. Idempotent:\nreturns 201 the first time the key is set, 200 on subsequent\nupdates. Same validation and write-only guarantees as POST.\n"
        },
        {
          "info": {
            "name": "Delete an org secret",
            "type": "http"
          },
          "http": {
            "method": "DELETE",
            "url": "https://api.primitive.dev/v1/org/secrets/:key",
            "params": [
              {
                "name": "key",
                "value": "",
                "type": "path",
                "description": "Secret key. Must match `^[A-Z_][A-Z0-9_]*$`."
              }
            ],
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Removes the org secret. Functions keep the previous value until\neach is redeployed. Returns 404 if the key did not exist.\n"
        },
        {
          "info": {
            "name": "List a function's execution logs",
            "type": "http"
          },
          "http": {
            "method": "GET",
            "url": "https://api.primitive.dev/v1/functions/:id/logs",
            "params": [
              {
                "name": "id",
                "value": "",
                "type": "path",
                "description": "Resource UUID"
              },
              {
                "name": "limit",
                "value": "",
                "type": "query",
                "description": "Maximum number of rows to return. Clamped to 1..200; default\n50.\n"
              },
              {
                "name": "cursor",
                "value": "",
                "type": "query",
                "description": "Opaque pagination cursor from a previous response's\n`next_cursor`. Omit on the first call.\n"
              }
            ],
            "auth": {
              "type": "bearer",
              "token": "{{bearerToken}}"
            }
          },
          "docs": "Returns the most recent `function_logs` rows for the function,\nnewest first. Each row is a single `console.log` / `console.error`\ninvocation captured from the running handler.\n\nPage through history with the opaque `cursor` returned as\n`next_cursor`; pass it back as the `cursor` query param on the\nnext call. `next_cursor` is `null` when there are no further\nrows. The cursor format is an implementation detail and should\nnot be parsed by callers.\n"
        }
      ]
    }
  ],
  "bundled": true
}