# Query available resources for agent construction

Read the resource collection in the current workspace that can be used to build the agent.

```text
GET https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/agent-builder/resources
```

## Preparation before calling

Prepare a personal access token and target workspace ID that has access to the target workspace.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through the `X-Workspace-ID` Header and also as `workspace_id` in the path.

## Request example

```bash
curl "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/agent-builder/resources" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | Workspace ID. |

## Successful response

Returns `200` on success. Use this response as `resources` in the candidate request and do not construct the resource reference yourself.

```json
{
  "code": 0,
  "data": {
    "models": [
      {
        "name": "<MODEL_NAME>",
        "model_config_ref": "mc_01"
      }
    ],
    "tools": [
      {
        "name": "<TOOL_NAME>"
      }
    ],
    "skills": [
      {
        "name": "<SKILL_NAME>"
      }
    ],
    "knowledge_bases": [
      {
        "name": "<KNOWLEDGE_BASE_NAME>"
      }
    ]
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `0` on success. |
| `data.models` | array | The models, tools, skills and knowledge base that can be used to build in the current workspace. |
| `data.tools` | array | The models, tools, skills and knowledge base that can be used to build in the current workspace. |
| `data.skills` | array | The models, tools, skills and knowledge base that can be used to build in the current workspace. |
| `data.knowledge_bases` | array | The models, tools, skills and knowledge base that can be used to build in the current workspace. |
| `name` for each array item | string | The name used by the candidate configuration to reference the resource. |
| `data.models[].model_config_ref` | string | The model configuration, model name, and display name that the model item can return. |
| `data.models[].model_name` | string | The model configuration, model name, and display name that the model item can return. |
| `data.models[].display_name` | string | The model configuration, model name, and display name that the model item can return. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Error response

```json
{
  "code": 5,
  "message": "<错误信息>"
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `401`
  - `6`（`UNAUTHENTICATED`）
  - Lack of valid identity credentials.
  - Check API Key.
* - `403`
  - `5`（`PERMISSION_DENIED`）
  - The current identity does not have permission to build an agent.
  - Check workspace authorization.
* - `413`
  - `14`（`RESOURCE_EXHAUSTED`）
  - The list of available resources exceeds the size allowed by the interface.
  - Narrow down the resource scope and try again.
* - `500`
  - `1`（`INTERNAL`）
  - Failed to read resource list.
  - Try again later; contact support if it continues to fail.
* - `503`
  - `15`（`UNAVAILABLE`）
  - The authoring resource service or licensing dependency is unavailable.
  - Try again later.
```

## Follow-up operations

Use the resource list [Generate agent candidate solutions](propose-candidate.md).
