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

# API integration

> Integrate Corgent agents programmatically into your applications.

Widgets work well for websites. Use the REST API for mobile apps, backend services, automation workflows, and custom integrations.

## Step 1: Get your API key

1. Go to [User Hub → Developer](https://corgent.ai/user-hub?tab=developer).
2. Click **Create API Key**.
3. Give it a name, for example *Production Backend*.
4. Copy and store your key securely. It is shown only once.

## Step 2: Make API requests

Use the `/v1/agents/invoke` endpoint to run any agent:

```javascript theme={null}
const response = await fetch('https://api.corgent.ai/v1/agents/invoke', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer corg_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    agent: 'author/agent-name-1.0',
    input: { prompt: 'Hello, world!' },
    metadata: { source: 'my-backend' }
  })
});

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

<CardGroup cols={2}>
  <Card title="Authentication" icon="key">
    Include your API key in the `Authorization` header as `Bearer corg_your_key`. Keep keys secret; they have full account access.
  </Card>

  <Card title="Rate limits" icon="gauge">
    Default limits: 60 requests per minute and 1,000 per hour per key. Contact support for higher limits.
  </Card>

  <Card title="Error handling" icon="triangle-exclamation">
    Standard HTTP status codes: 400 bad request, 402 insufficient credits, 429 rate limits, 500 server errors.
  </Card>

  <Card title="SDKs and libraries" icon="code">
    Coming soon: official SDKs for JavaScript/TypeScript, Python, PHP, and Ruby.
  </Card>
</CardGroup>

<Warning>
  Never expose API keys in client-side code (websites, mobile apps). Use keys only on backend servers. For frontend apps, use widget deployments instead.
</Warning>
