Connect an API
Connect your orders API so the agent can look up an order's status. Store the credential as a secret, define the call, test it and assign the tool to the agent.
Before you start
- An agent (create one), with its id in
AGENT_ID. - An endpoint in your system that returns JSON.
If the endpoint needs no credential, skip step 1.
In the platform: REST APIs and Secrets.
Store the credential as a secret
Store the token with Create a secret. Reads return its identifier, not the value.
curl https://api.platic.ai/v1/secrets \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Acme · Orders API", "kind": "bearer", "value": "<your API token>" }'import { Platic } from "platic-sdk"; const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! }); const agentId = process.env.AGENT_ID!; const secret = await platic.secrets.create({ name: "Acme · Orders API", kind: "bearer", value: process.env.ACME_API_TOKEN!, });Store the token of Acme's orders API as a secret.
Tool:
create_secret. To keep the token out of the chat, store it yourself in Integrations → Functions → Secrets and ask it to use that one.The response has the secret's
id, never the value. Keep it inSECRET_ID.Define the API
Define the URL, input data and when the agent should use it. Bind the secret to the
auth.tokenfield instead of including its value. (Create an API tool)curl https://api.platic.ai/v1/tools/apis \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "order_lookup", "description": "Looks up the status of an order by its number. Use it when the customer asks where their order is.", "request": { "method": "GET", "url": "https://api.acme.com/orders/{{orderId}}", "auth": { "type": "bearer" } }, "variables": [ { "name": "orderId", "type": "string", "description": "Order number, as it appears in the confirmation email.", "required": true } ], "secrets": { "auth.token": "'$SECRET_ID'" } }'const api = await platic.tools.apis.create({ name: "order_lookup", description: "Looks up the status of an order by its number. Use it when the customer asks where their order is.", request: { method: "GET", url: "https://api.acme.com/orders/{{orderId}}", auth: { type: "bearer" }, }, variables: [ { name: "orderId", type: "string", description: "Order number, as it appears in the confirmation email.", required: true }, ], secrets: { "auth.token": secret.id }, });Create a tool that looks up an order's status: a GET to https://api.acme.com/orders/ followed by the order number, with the orders API secret. Use it when a customer asks where their order is.
Tool:
create_api_tool.The API is created as a draft. Save its
idinAPI_IDand readnextStepto see what remains.Test it and publish it
Test the API with an order: this call executes your endpoint. Check the result, then publish it in the workspace catalog.
curl https://api.platic.ai/v1/tools/apis/$API_ID/test \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "input": { "orderId": "AC-48210" } }' curl -X POST https://api.platic.ai/v1/tools/apis/$API_ID/enable \ -H "Authorization: Bearer $PLATIC_API_KEY"await platic.tools.apis.test(api.id, { input: { orderId: "AC-48210" } }); await platic.tools.apis.enable(api.id);Test the orders tool with order number AC-48210 and, if it works, publish it.
Tool:
test_api_toolandenable_api_tool.Check
extracted: it contains the data the agent will receive. It should include the information needed to answer.Connect it to the agent
Connect the tool using the API's id. The connection applies immediately; you do not need to publish the agent.
curl -X PUT https://api.platic.ai/v1/agents/$AGENT_ID/tools/$API_ID \ -H "Authorization: Bearer $PLATIC_API_KEY"await platic.agents.tools.connect(agentId, api.id);Give the orders tool to the Sales agent.
Tool:
connect_agent_tool.
Check it worked
Call List the agent's tools: order_lookup should appear. Ask the agent about an order and check that it requests the number and calls your API.
When you edit the API, it returns to draft. Agents stop using it until you bind the secret again, test it and publish it.
Next steps
- Connect an MCP server if the tools you need already exist in one.
- Write a custom function when one HTTP call is not enough.
- Test it before you publish: a scenario can require the agent to call your API.
- Custom APIs: credential slots, lifecycle and what happens when you edit.