> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# API Execution

> Learn how to invoke Devic agents through the API to integrate them with your applications or custom workflows.

**Devic** agents can be executed not only from the visual interface, but also **programmatically** through the public API.\
This allows you to integrate agents into external systems, automate workflows, or connect them with other corporate applications.

Each agent has a **dedicated endpoint** that lets you create new executions (threads) by sending instructions directly via HTTP.

***

## Base Endpoint

Each agent has a unique URL for creating executions:

`POST https://api.devic.ai/v1/agents/{agent_id}/threads`

The `{agent_id}` parameter is obtained from the agent’s view, in the **“Agent API Documentation”** dialog.

<img src="https://mintcdn.com/devic/ZT3uSt-Hz5vXgxUW/api-execution-agent.png?fit=max&auto=format&n=ZT3uSt-Hz5vXgxUW&q=85&s=c1c41bee206eb070d8f9c14507e2bedb" alt="Agent API panel view" width="1912" height="940" data-path="api-execution-agent.png" />

***

## Usage Example

You can invoke an agent using any language that supports HTTP requests (JavaScript, Python, cURL, etc.).\
Below is an example in **JavaScript** using `fetch`:

```javascript theme={null}
const response = await fetch('https://api.devic.ai/v1/agents/{agent_id}/threads', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  body: JSON.stringify({
    message: 'Process the monthly sales report',
    state: 'queued'
  })
});

const data = await response.json();
console.log(data);
```
