---
docId: doc_dc3708411bbb4de9b9b84a22f5a6f903
title: 'Custom APIs'
description: 'Turn any public HTTP endpoint into a tool for your agents: draft, secrets, real test and publishing to the catalog.'
---

<script>
  import { Ways } from '$lib/components';
</script>

# Custom APIs

Let an agent call a public HTTP endpoint in your service. [Define the request](/api-reference/custom-apis/create), bind credentials as [secrets](/api-reference/secrets), [test it](/api-reference/custom-apis/test) and [publish it](/api-reference/custom-apis/publish). Then [connect the tool to the agent](/api-reference/agents/tools/connect) so it can use it. Use variables to fill the request with conversation data.

## Quick example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
# Cycle: create (draft) -> bind secrets -> test -> publish (enabled) -> connect to the agent
curl -X POST https://api.platic.ai/v1/tools/apis/$API_ID/test \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input": {"order": "1001"}}'

curl -X POST https://api.platic.ai/v1/tools/apis/$API_ID/enable \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
// 1. Create the API as a draft
const api = await platic.tools.apis.create({
  name: "order_status",
  description: "Looks up an order by its number.",
  request: {
    method: "GET",
    url: "https://api.example-store.com/orders",
    params: [{ key: "number", value: "{{order}}" }],
    auth: { type: "bearer" },
  },
  variables: [{ name: "order", type: "string", description: "Order number", required: true, mode: "ai" }],
  secrets: { "auth.token": secretId },
});

// 2. Real test (required to publish) -> publish -> connect to the agent
const test = await platic.tools.apis.test(api.id, { input: { order: "1001" } });
if (test.success) {
  const { toolId } = await platic.tools.apis.enable(api.id);
  await platic.agents.tools.connect(agentId, toolId);
}
```

</Ways.Way>
</Ways>

## What you need to know

- **Variables (`mode`):** `ai` (the agent fills it; it generates its JSON Schema), `constant` (fixed value in `constantValue`), `context` (comes from the conversation through `contextField`) and `secret` (comes from the `variable:<name>` slot).
- **Credentials in slots:** `auth.token` (`bearer`), `auth.password` (`basic`), `auth.value` (`apikey`), `encryptPayload.key`, `header:<name>` and `variable:<name>`. Sending credentials inline answers `400 SECRET_REFERENCE_REQUIRED`.
- **Editing invalidates the test:** when you [update the API](/api-reference/custom-apis/update), `verified` goes back to `false`, secrets become `needs_authorization` and, if it was `enabled`, it goes back to `draft` (keeping its connections to agents). [Bind](/api-reference/custom-apis/bind-secret), [test](/api-reference/custom-apis/test) and [publish](/api-reference/custom-apis/publish) again.
- **Security:** public URLs only (it blocks `localhost` and private networks). Binding secrets requires `https`. Sensitive values come back as `"[REDACTED]"`.

## Endpoints

| Method | Endpoint | What it does |
|--------|----------|--------------|
| `GET` / `POST` | [`/v1/tools/apis`](/api-reference/custom-apis/list) | List APIs or [create one](/api-reference/custom-apis/create) as `draft` |
| `GET` / `PATCH` / `DELETE` | [`/v1/tools/apis/{integrationId}`](/api-reference/custom-apis/get) | Get, [edit](/api-reference/custom-apis/update) or [delete](/api-reference/custom-apis/delete) |
| `POST` | [`/v1/tools/apis/{integrationId}/secrets`](/api-reference/custom-apis/bind-secret) | Bind a secret to a slot |
| `POST` | [`/v1/tools/apis/{integrationId}/test`](/api-reference/custom-apis/test) | Test it (`dryRun` or real test) |
| `POST` | [`/v1/tools/apis/{integrationId}/enable`](/api-reference/custom-apis/publish) | Publish to the catalog (`enabled`) |
| `POST` | [`/v1/tools/apis/{integrationId}/pause`](/api-reference/custom-apis/pause) | Pause without losing configuration |
| `POST` | [`/v1/tools/apis/{integrationId}/clone`](/api-reference/custom-apis/clone) | Clone as a new draft |

## Errors

Errors follow the format in [Errors](/api-reference/errors): `{ code, error, details: { code, message, ... } }`. These are the `details.code` values of this section; each page says which ones it can answer.

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | The body or parameters fail validation, or the credential covers several workspaces and `workspace` is missing. `details.issues` has the list of problems |
| `401` | `UNAUTHENTICATED` | The credential is missing, or revoked or expired |
| `400` | `INVALID_CONFIG` | The definition is not valid, or `request.url` points to localhost, `.local`, `.internal` or a private IP |
| `400` | `SECRET_REFERENCE_REQUIRED` | You sent a credential inside the definition. When it applies, `details.slot` says the slot to bind |
| `400` | `SECRET_SLOT_INVALID` | That slot does not exist in the API's current configuration |
| `400` | `SECRET_DESTINATION_INVALID` | The API does not have a valid `https` URL |
| `400` | `SECRET_VARIABLE_CONFIGURATION_INVALID` | A `secret` variable is outside headers, query parameters or body |
| `403` | `FORBIDDEN` | The person behind the token does not have access to Integrations |
| `404` | `NOT_FOUND` | The API does not exist in this workspace |
| `404` | `SECRET_NOT_FOUND` | The secret does not exist in this workspace |
| `404` | `CRON_NOT_FOUND` | `periodicAuth.cronJobId` does not exist |
| `409` | `RESOURCE_CHANGED` | `expectedVersion` does not match, or the API changed while it was being saved. Read it and repeat |
| `409` | `NAME_CONFLICT` | The name is already used by another tool |
| `409` | `VERIFICATION_REQUIRED` | There is no valid real test. [Test](/api-reference/custom-apis/test) and repeat |
| `409` | `SECRET_AUTHORIZATION_REQUIRED` | A secret is missing on a `secret` variable |
| `409` | `AUTHORIZATION_CHANGED` | A secret changed during the test. Repeat the call |
| `409` | `SECRET_USE_REVOKED` | The secret is revoked or expired |
| `409` | `SECRET_CHANGED` | The secret changed while it was being bound. Repeat the call |
| `409` | `SECRET_BINDING_LIMIT` | The API already has the maximum number of bound secrets |
| `409` | `DELETION_IN_PROGRESS` | The deletion is already in progress. Repeat the call to continue it |

Slot states are in [Secrets](/api-reference/secrets#slot-states) and AI tools in the [Tools MCP tools](/mcp/tools#tools).
