---
docId: doc_c5c07344743944f4a438515418adcec4
title: Give your agent files
description: "Add a file to your agent's knowledge, share it with another agent and pause its use."
---

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

# Give your agent files

<span id="what-youll-build"></span>

Add a file with business information for the agent to consult when answering. The example uses your opening hours. Once processed, you can connect the same file to another agent or pause its use.

## Before you start

You need an agent ([create one](/guides/create-an-agent)) with its id in `AGENT_ID`.

In the platform: [Knowledge](/help/agents/knowledge).

<Steps>
<Steps.Step>

**Create the file, connected to the agent**

[Create the file](/api-reference/files/create) in the workspace and connect it to the agent in the same call. It can be text, a web page or a document.

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

```bash
curl https://api.platic.ai/v1/files \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "text",
    "title": "Opening hours",
    "text": "We are open Monday to Friday from 9:00 to 18:00 and on Saturdays from 10:00 to 14:00.",
    "attachment": { "agentId": "'$AGENT_ID'" }
  }'
```

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

```ts
import { Platic } from "platic-sdk";

const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! });
const agentId = process.env.AGENT_ID!;

// For a web page use createUrl; for a document (up to 50 MiB), createFile.
const file = await platic.files.createText({
  title: "Opening hours",
  text: "We are open Monday to Friday from 9:00 to 18:00 and on Saturdays from 10:00 to 14:00.",
  attachment: { agentId },
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Give the Sales agent a file with our opening hours: Monday to Friday from 9:00 to 18:00 and Saturdays from 10:00 to 14:00.

</Ways.Say>

Tool: [`create_file`](/mcp/tools#create_file).

</Ways.Way>
</Ways>

The response has `fileId` and `uploadId`: keep them in `FILE_ID` and `UPLOAD_ID`. For a web page or a document, see [Create a file](/api-reference/files/create).

</Steps.Step>
<Steps.Step>

**Wait until it is ready**

Check the [processing status](/api-reference/agents/files/processing). When it finishes, the connection to the agent activates automatically.

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

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/files/$FILE_ID/jobs/$UPLOAD_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

Repeat it every few seconds until `terminal` is `true`.

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

```ts
const job = await platic.agents.files.waitForJob(agentId, file.fileId, file.uploadId);
if (job.status === "failed") {
  throw new Error(job.error?.message ?? "The file could not be processed");
}
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Is the Sales opening-hours file ready yet?

</Ways.Say>

Tool: [`get_agent_file_job`](/mcp/tools#get_agent_file_job).

</Ways.Way>
</Ways>

The file is available to the agent when `status: "ready"`. If it ends as `failed`, read the reason in `error`.

</Steps.Step>
<Steps.Step>

**Share it with another agent**

The file is already in your workspace: connect it, don't upload it again. ([Connect a file](/api-reference/agents/files/connect))

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

```bash
curl -X PUT https://api.platic.ai/v1/agents/$SUPPORT_AGENT_ID/files/$FILE_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

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

```ts
const supportAgentId = process.env.SUPPORT_AGENT_ID!;

await platic.agents.files.connect(supportAgentId, file.fileId);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Connect the opening-hours file to the Support agent too.

</Ways.Say>

Tool: [`connect_agent_file`](/mcp/tools#connect_agent_file).

</Ways.Way>
</Ways>

If you update the file later, it changes for every agent that uses it.

</Steps.Step>
<Steps.Step>

**Pause it when it no longer applies**

[Pause the file](/api-reference/agents/files/schedule) to stop this agent from using it. The connection and file remain; other agents are unaffected.

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

```bash
curl -X PATCH https://api.platic.ai/v1/agents/$AGENT_ID/files/$FILE_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "state": "paused" }'
```

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

```ts
await platic.agents.files.setState(agentId, file.fileId, "paused");
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Pause the opening-hours file on Sales.

</Ways.Say>

Tool: [`set_agent_file_state`](/mcp/tools#set_agent_file_state).

</Ways.Way>
</Ways>

To turn it back on, use `active`. You can also schedule both changes with a date: see [Pause or schedule a file](/api-reference/agents/files/schedule).

</Steps.Step>
</Steps>

## Check it worked

Call [List the agent's files](/api-reference/agents/files/list) and check the file's state. Ask the agent about opening hours and compare its reply with the content. Connecting, pausing and disconnecting apply immediately, without publishing the agent.

To take it away from one agent, [disconnect it](/api-reference/agents/files/disconnect): the file stays in your workspace. To delete it for everyone, [delete it](/api-reference/files/delete).

## Next steps

- [Connect an API](/guides/connect-an-api) to look up information or perform actions in your system.
- [Test it before you publish](/guides/evals): check that it answers with what its files say.
- [Files](/api-reference/files): file types, limits and pages that update themselves.
