# Assign

Attach a resource (rule, MCP config, skill, vault, integration, or model) to an agent.





```http
POST /api/public/v1/agents/{agent_id}/resources
```

`{agent_id}` accepts either the ULID (`cci_...`) or the human-readable slug (the agent's `agent_id` field).

## Request body [#request-body]

<TypeTable
  type="{
  entity_type: {
    type: &#x22;string&#x22;,
    required: true,
    description: &#x22;Type of resource. See the table below.&#x22;
  },
  entity_id: {
    type: &#x22;string&#x22;,
    required: true,
    description: &#x22;ID of the resource to attach. Format depends on `entity_type`.&#x22;
  }
}"
/>

## Entity types [#entity-types]

| Type                            | `entity_id` format                       | Description                                                                                                        |
| ------------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `agent_artifact_rule`           | `aar_…`                                  | Rule artifact                                                                                                      |
| `agent_artifact_mcp_cfg`        | `amc_…`                                  | MCP configuration artifact                                                                                         |
| `agent_artifact_skill`          | `ask_…`                                  | Skill artifact                                                                                                     |
| `vault`                         | `vlt_…`                                  | Secrets vault                                                                                                      |
| `github_repository_integration` | ULID                                     | GitHub repository integration (list IDs via [GET /integrations/github-repos](/api/integrations/list-github-repos)) |
| `anthropic_integration`         | `ai_…`                                   | Anthropic API integration (list IDs via [GET /integrations/llm](/api/integrations/list-llm))                       |
| `llm_model`                     | model slug (`opus-4.5`, `sonnet-4.6`, …) | LLM model configuration (list available models via [GET /models](/api/models/list))                                |

If the referenced entity does not exist, the response is `404 Not Found` (not `400`).

## Example [#example]

<Tabs items="[&#x22;bash&#x22;, &#x22;TypeScript&#x22;, &#x22;Ruby&#x22;, &#x22;Python&#x22;, &#x22;Go&#x22;]">
  <Tab value="bash">
    ```bash
    curl -X POST https://api.nairi.ai/api/public/v1/agents/AGENT_ID/resources \
      -H "Authorization: Bearer $NAIRI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "entity_type": "agent_artifact_rule",
        "entity_id": "aar_01KJWRKX0ZNZP91YG3Q353776Q"
      }'
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    const res = await fetch(
      `https://api.nairi.ai/api/public/v1/agents/${agentId}/resources`,
      {
        method: "POST",
        headers: {
          Authorization: `Bearer ${process.env.NAIRI_API_KEY}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          entity_type: "agent_artifact_rule",
          entity_id: "aar_01KJWRKX0ZNZP91YG3Q353776Q",
        }),
      },
    );
    const data = (await res.json()) as { id: string };
    ```
  </Tab>

  <Tab value="Ruby">
    ```ruby
    require "net/http"
    require "json"
    require "uri"

    uri = URI("https://api.nairi.ai/api/public/v1/agents/#{agent_id}/resources")
    req = Net::HTTP::Post.new(uri)
    req["Authorization"] = "Bearer #{ENV['NAIRI_API_KEY']}"
    req["Content-Type"] = "application/json"
    req.body = {
      entity_type: "agent_artifact_rule",
      entity_id: "aar_01KJWRKX0ZNZP91YG3Q353776Q",
    }.to_json

    res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.request(req) }
    data = JSON.parse(res.body)
    ```
  </Tab>

  <Tab value="Python">
    ```python
    import os
    import requests

    res = requests.post(
        f"https://api.nairi.ai/api/public/v1/agents/{agent_id}/resources",
        headers={
            "Authorization": f"Bearer {os.environ['NAIRI_API_KEY']}",
            "Content-Type": "application/json",
        },
        json={
            "entity_type": "agent_artifact_rule",
            "entity_id": "aar_01KJWRKX0ZNZP91YG3Q353776Q",
        },
    )
    data = res.json()
    ```
  </Tab>

  <Tab value="Go">
    ```go
    package main

    import (
    	"bytes"
    	"encoding/json"
    	"fmt"
    	"io"
    	"net/http"
    	"os"
    )

    func main() {
    	agentID := os.Getenv("AGENT_ID")
    	body, _ := json.Marshal(map[string]any{
    		"entity_type": "agent_artifact_rule",
    		"entity_id":   "aar_01KJWRKX0ZNZP91YG3Q353776Q",
    	})
    	req, _ := http.NewRequest(
    		"POST",
    		"https://api.nairi.ai/api/public/v1/agents/"+agentID+"/resources",
    		bytes.NewReader(body),
    	)
    	req.Header.Set("Authorization", "Bearer "+os.Getenv("NAIRI_API_KEY"))
    	req.Header.Set("Content-Type", "application/json")
    	res, _ := http.DefaultClient.Do(req)
    	defer res.Body.Close()
    	raw, _ := io.ReadAll(res.Body)
    	var data map[string]any
    	json.Unmarshal(raw, &data)
    	fmt.Println(data)
    }
    ```
  </Tab>
</Tabs>

## Response: `201 Created` [#response-201-created]

```json
{
  "id": "ccr_01KRK2A1B2C3D4E5F6G7H8J9K0",
  "container_id": "cci_01KEQ6963XS96YDP3NF9NKB7QJ",
  "entity_type": "agent_artifact_rule",
  "entity_id": "aar_01KJWRKX0ZNZP91YG3Q353776Q",
  "created_at": "2026-04-12T18:45:12.000Z"
}
```
