API quickstart

Make your first Fetchply API calls, chat with an agent from your own code, and keep its knowledge in sync with your systems.

You need an API key with the permissions used below.

1. Find your agent ID

curl https://fetchply.com/api/v1/agents \
  -H "Authorization: Bearer fp_live_YOUR_KEY"
{ "items": [{ "id": "a1b2c3d4e5", "name": "Acme Support", "status": "ready", "answerLanguage": "en" }] }

2. Chat with the agent

POST /agents/{id}/chat needs write:chat:

curl -X POST https://fetchply.com/api/v1/agents/AGENT_ID/chat \
  -H "Authorization: Bearer fp_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "What are your opening hours?"}'
{
  "agentId": "a1b2c3d4e5",
  "sessionId": "api_7f3f0c9a-6a5e-4a2b-9d1c-3d2f1e0a9b8c",
  "reply": "We are open Monday to Friday, 9am to 6pm CET.",
  "sources": [{ "title": "Contact us", "url": "https://acme.com/contact" }]
}
  • Send the returned sessionId with the next message to continue the conversation. Your own ID works too: 8 to 200 letters, digits, ., -, _, or :. An ID already used by another agent or channel returns 409 session_conflict.
  • Pass a clientMessageId to make retries safe: repeats of the same message never use extra credits.
  • Pass location (country, countryCode, city, region) for localized answers such as shipping.
  • message can be up to 4,000 characters. Replies are Markdown text.
  • Each reply uses message credits like any other channel. With none left you get 402 insufficient_credits; while the agent is still training, 409 agent_not_ready.
  • Conversations appear in the dashboard Inbox under the API channel.

3. Keep knowledge in sync

Add a page, text, or file when your content changes (write:sources):

# A public web page
curl -X POST https://fetchply.com/api/v1/agents/AGENT_ID/sources \
  -H "Authorization: Bearer fp_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type": "url", "url": "https://acme.com/pricing"}'

# Text
curl -X POST https://fetchply.com/api/v1/agents/AGENT_ID/sources \
  -H "Authorization: Bearer fp_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type": "text", "title": "Refund policy", "content": "Refunds are available within 30 days."}'

# A file, as multipart form data
curl -X POST https://fetchply.com/api/v1/agents/AGENT_ID/sources/files \
  -H "Authorization: Bearer fp_live_YOUR_KEY" \
  -F "[email protected]"

Sources are learned in the background. Poll GET /agents/{id}/sources until status is indexed, or failed with the reason in errorMessage.

  • Text sources hold up to about 1 MB of text. Files can be PDF, DOCX, PPTX, CSV, XLS, XLSX, TXT, Markdown, HTML, JSON, PNG, JPEG, WebP, or GIF, up to 10 MB.
  • Only text sources can be edited in place with PATCH. Refresh pages with POST /agents/{id}/retrain and watch GET /agents/{id}/training-status.
  • One training job runs per agent at a time; a second returns 409 training_in_progress.
  • 403 training_limit_exceeded means your plan's storage is full.

4. Check what the agent knows

curl "https://fetchply.com/api/v1/agents/AGENT_ID/knowledge/search?query=refund%20policy" \
  -H "Authorization: Bearer fp_live_YOUR_KEY"

Returns the most relevant passages with their source, using no message credits. An empty list means nothing matched, which is a good candidate for a new source or Q&A pair.

Next

Browse the endpoint pages in this tab, or connect an AI assistant with the MCP server.