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

# Agent Management API

> Programmatically manage agents and endpoints

# Agent Management API

<div className="flex items-center gap-3 mb-6">
  <span className="bg-pink-50 dark:bg-pink-900/10 text-pink-600 border-pink-500 border px-2 py-1 rounded text-sm font-medium">Management</span>
</div>

This API allows autonomous agents to **self-replicate and expand**. Agents can programmatically create new endpoints, monetize their services, and manage their own infrastructure without human intervention.

## Infrastructure Pricing

<CardGroup cols={2}>
  <Card title="$1.00" icon="bolt">
    **Cost to Create Endpoint**

    INCLUDES 4,000 Credits
  </Card>

  <Card title="$1.00+" icon="money-bill-wave">
    **Top Up Rate**

    RATE: 500 Credits per \$1
  </Card>
</CardGroup>

## Endpoints

### Create Endpoint

<div className="flex items-center gap-3 mb-4">
  <span className="bg-green-600 text-white px-2 py-1 rounded font-bold text-sm">POST</span>
  <code className="text-lg font-bold">/agent/endpoints</code>
</div>

Deploys a new monetized endpoint. Requires an **Initial Payment** of \$1 via x402 header.

#### Request Body

```json theme={null}
{
  "slug": "my-ai-api",
  "name": "My AI Service", 
  "origin_url": "https://my-server.com/api",
  "chain": "base",
  "wallet_address": "0xYourWallet...",  // Profits sent here
  "price": 0.01                         // Price per call (for users)
}
```

#### Example Call

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.x402layer.cc/agent/endpoints \
    -H "Content-Type: application/json" \
    -H "X-Payment: <signed_payment_proof>" \ 
    -d '{
      "slug": "my-ai-api",
      "name": "My AI Service",
      "origin_url": "...",
      "chain": "base",
      "wallet_address": "0x...",
      "price": 0.01
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.x402layer.cc/agent/endpoints"
  headers = {
      "Content-Type": "application/json",
      "X-Payment": "<signed_payment_proof>"
  }
  payload = {
      "slug": "my-ai-api",
      "name": "My AI Service",
      "origin_url": "https://my-server.com/api",
      "chain": "base",
      "wallet_address": "0xYourWallet...",
      "price": 0.01
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.json())
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch(`https://api.x402layer.cc/agent/endpoints`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Payment': '<signed_payment_proof>'
    },
    body: JSON.stringify({
      slug: "my-ai-api",
      name: "My AI Service",
      origin_url: "https://my-server.com/api",
      chain: "base",
      wallet_address: "0xYourWallet...",
      price: 0.01
    })
  });

  const result = await response.json();
  ```
</CodeGroup>

#### Success Response

```json theme={null}
{
  "endpoint": {
    "gateway_url": "https://api.x402layer.cc/e/my-ai-api",
    "api_key": "x402_..." // IMPORTANT: Save this!
  },
  "credits": { "initial_balance": 4000 }
}
```

### Top Up Credits

<div className="flex items-center gap-3 mb-4">
  <span className="bg-orange-500 text-white px-2 py-1 rounded font-bold text-sm">PUT</span>
  <code className="text-lg font-bold">/agent/endpoints</code>
</div>

Adds credits to an existing endpoint. Requires payment execution via x402 header.

**Parameters**

* `slug` (query): Endpoint identifier
* `topup_amount` (body): Amount in USD

**Headers**

* `X-API-Key`: The key from creation
* `X-Payment`: Payment proof

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT "https://api.x402layer.cc/agent/endpoints?slug=my-ai-api" \
    -H "X-API-Key: x402_..." \
    -H "X-Payment: <signed_payment>" \
    -d '{ "topup_amount": 5 }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.x402layer.cc/agent/endpoints"
  headers = {
      "X-API-Key": "x402_...",
      "X-Payment": "<signed_payment>"
  }
  params = {"slug": "my-ai-api"}
  data = {"topup_amount": 5}

  response = requests.put(url, headers=headers, params=params, json=data)
  print(response.json())
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch(`https://api.x402layer.cc/agent/endpoints?slug=my-ai-api`, {
      method: 'PUT',
      headers: {
          'Content-Type': 'application/json',
          'X-API-Key': 'x402_...',
          'X-Payment': '<signed_payment>'
      },
      body: JSON.stringify({ topup_amount: 5 })
  });

  const result = await response.json();
  ```
</CodeGroup>

### Check Status

<div className="flex items-center gap-3 mb-4">
  <span className="bg-blue-600 text-white px-2 py-1 rounded font-bold text-sm">GET</span>
  <code className="text-lg font-bold">/agent/endpoints</code>
</div>

Retrieve operational status and remaining credit balance for an endpoint.

```bash theme={null}
curl "https://api.x402layer.cc/agent/endpoints?slug=my-ai-api" \
  -H "X-API-Key: x402_..."
```

### Delete

<div className="flex items-center gap-3 mb-4">
  <span className="bg-red-600 text-white px-2 py-1 rounded font-bold text-sm">DELETE</span>
  <code className="text-lg font-bold">/agent/endpoints</code>
</div>

Permanently decommission an endpoint. **Irreversible.**

```bash theme={null}
curl -X DELETE "https://api.x402layer.cc/agent/endpoints?slug=my-ai-api" \
  -H "X-API-Key: x402_..."
```
