Custom APIs

Let an agent call a public HTTP endpoint in your service. Define the request, bind credentials as secrets, test it and publish it. Then connect the tool to the agent so it can use it. Use variables to fill the request with conversation data.

Quick example

// 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);
}

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, 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, test and publish again.
  • Security: public URLs only (it blocks localhost and private networks). Binding secrets requires https. Sensitive values come back as "[REDACTED]".

Endpoints

MethodEndpointWhat it does
GET / POST/v1/tools/apisList APIs or create one as draft
GET / PATCH / DELETE/v1/tools/apis/{integrationId}Get, edit or delete
POST/v1/tools/apis/{integrationId}/secretsBind a secret to a slot
POST/v1/tools/apis/{integrationId}/testTest it (dryRun or real test)
POST/v1/tools/apis/{integrationId}/enablePublish to the catalog (enabled)
POST/v1/tools/apis/{integrationId}/pausePause without losing configuration
POST/v1/tools/apis/{integrationId}/cloneClone as a new draft

Errors

Errors follow the format in Errors: { code, error, details: { code, message, ... } }. These are the details.code values of this section; each page says which ones it can answer.

Statusdetails.codeWhen
400INVALID_REQUESTThe body or parameters fail validation, or the credential covers several workspaces and workspace is missing. details.issues has the list of problems
401UNAUTHENTICATEDThe credential is missing, or revoked or expired
400INVALID_CONFIGThe definition is not valid, or request.url points to localhost, .local, .internal or a private IP
400SECRET_REFERENCE_REQUIREDYou sent a credential inside the definition. When it applies, details.slot says the slot to bind
400SECRET_SLOT_INVALIDThat slot does not exist in the API's current configuration
400SECRET_DESTINATION_INVALIDThe API does not have a valid https URL
400SECRET_VARIABLE_CONFIGURATION_INVALIDA secret variable is outside headers, query parameters or body
403FORBIDDENThe person behind the token does not have access to Integrations
404NOT_FOUNDThe API does not exist in this workspace
404SECRET_NOT_FOUNDThe secret does not exist in this workspace
404CRON_NOT_FOUNDperiodicAuth.cronJobId does not exist
409RESOURCE_CHANGEDexpectedVersion does not match, or the API changed while it was being saved. Read it and repeat
409NAME_CONFLICTThe name is already used by another tool
409VERIFICATION_REQUIREDThere is no valid real test. Test and repeat
409SECRET_AUTHORIZATION_REQUIREDA secret is missing on a secret variable
409AUTHORIZATION_CHANGEDA secret changed during the test. Repeat the call
409SECRET_USE_REVOKEDThe secret is revoked or expired
409SECRET_CHANGEDThe secret changed while it was being bound. Repeat the call
409SECRET_BINDING_LIMITThe API already has the maximum number of bound secrets
409DELETION_IN_PROGRESSThe deletion is already in progress. Repeat the call to continue it

Slot states are in Secrets and AI tools in the Tools MCP tools.