# Tool Repository

{% hint style="danger" %}
**Deprecated in v0.9.44**: All tool repository browsing endpoints have been removed. Tool source code is now managed exclusively through the [Agent Forge CLI](https://docs.amigo.ai/reference/agent-forge) and direct repository access. Tool publishing, versioning, and execution through the [Tools API](https://docs.amigo.ai/developer-guide/classic-api/core-api/tools) are unaffected.
{% endhint %}

{% hint style="info" %}
**Conceptual Docs**: For an overview of how actions and their source code fit into the platform, see the [Actions documentation](https://docs.amigo.ai/agent/actions).
{% endhint %}

The Tool Repository API previously provided read-only access to the version-controlled source code behind an organization's tools. These endpoints have been removed as of v0.9.44. Use the Agent Forge CLI for source code management.

**Permission required:** `Tool:AccessRepo` for all endpoints below.

## Access Management

Organization administrators control which users can browse the tool repository. Repository access is granted and revoked independently of tool execution permissions.

### Grant Repository Access

Grant a user read access to the organization's tool repository.

|                |                                                      |
| -------------- | ---------------------------------------------------- |
| **Method**     | `POST`                                               |
| **Path**       | `/v1/{organization}/user/{user_id}/tool-repo-access` |
| **Permission** | `User:UpdateUserInfo`                                |
| **Response**   | `200 OK`                                             |

### Revoke Repository Access

Remove a user's read access to the tool repository.

|                |                                                      |
| -------------- | ---------------------------------------------------- |
| **Method**     | `DELETE`                                             |
| **Path**       | `/v1/{organization}/user/{user_id}/tool-repo-access` |
| **Permission** | `User:UpdateUserInfo`                                |
| **Response**   | `204 No Content`                                     |

## Branches

### List Branches

List all branches in the tool repository with pagination.

|                |                                       |
| -------------- | ------------------------------------- |
| **Method**     | `GET`                                 |
| **Path**       | `/v1/{organization}/tool/repo/branch` |
| **Rate Limit** | 60 requests/min                       |

**Query Parameters**

| Parameter            | Type    | Default | Description                     |
| -------------------- | ------- | ------- | ------------------------------- |
| `limit`              | integer | 20      | Max branches to return (max 20) |
| `continuation_token` | integer | 1       | Pagination token                |

**Response**

| Field                         | Type            | Description                          |
| ----------------------------- | --------------- | ------------------------------------ |
| `branches`                    | array           | List of branch objects               |
| `branches[].name`             | string          | Branch name                          |
| `branches[].commit_sha`       | string          | Latest commit SHA                    |
| `branches[].commit_message`   | string          | Latest commit message                |
| `branches[].commit_timestamp` | datetime        | Latest commit timestamp              |
| `branches[].committer`        | object or null  | `{org_id, user_id}` of the committer |
| `continuation_token`          | integer or null | Token for the next page              |
| `has_more`                    | boolean         | Whether more branches exist          |

### Get Branch

Get details for a single branch.

|                |                                                     |
| -------------- | --------------------------------------------------- |
| **Method**     | `GET`                                               |
| **Path**       | `/v1/{organization}/tool/repo/branch/{branch_name}` |
| **Rate Limit** | 60 requests/min                                     |

**Response**

| Field              | Type           | Description                          |
| ------------------ | -------------- | ------------------------------------ |
| `commit_sha`       | string         | Latest commit SHA                    |
| `commit_message`   | string         | Latest commit message                |
| `commit_timestamp` | datetime       | Latest commit timestamp              |
| `committer`        | object or null | `{org_id, user_id}` of the committer |

## Commits

### List Commits

Browse commit history with optional filtering by branch, file path, and date range.

|                |                                       |
| -------------- | ------------------------------------- |
| **Method**     | `GET`                                 |
| **Path**       | `/v1/{organization}/tool/repo/commit` |
| **Rate Limit** | 60 requests/min                       |

**Query Parameters**

| Parameter                | Type     | Default  | Description                                   |
| ------------------------ | -------- | -------- | --------------------------------------------- |
| `ref`                    | string   | `"main"` | Branch name or commit SHA                     |
| `path`                   | string   | -        | Filter commits that touch this file path      |
| `committed_on_or_after`  | datetime | -        | Only commits after this timestamp (UTC)       |
| `committed_on_or_before` | datetime | -        | Only commits before this timestamp (UTC)      |
| `show_changed_files`     | boolean  | false    | Include list of changed file paths per commit |
| `show_change_stats`      | boolean  | false    | Include addition/deletion counts per commit   |
| `limit`                  | integer  | 20       | Max commits to return (max 20)                |
| `continuation_token`     | integer  | 1        | Pagination token                              |

**Response**

| Field                        | Type            | Description                                                      |
| ---------------------------- | --------------- | ---------------------------------------------------------------- |
| `commits`                    | array           | List of commit objects                                           |
| `commits[].commit_sha`       | string          | Commit SHA                                                       |
| `commits[].commit_message`   | string          | Commit message                                                   |
| `commits[].commit_timestamp` | datetime        | Commit timestamp                                                 |
| `commits[].committer`        | object or null  | `{org_id, user_id}` of the committer                             |
| `commits[].changed_files`    | object          | Map of `{path: "added"\|"modified"\|"deleted"}` (when requested) |
| `commits[].change_stats`     | object or null  | `{additions, deletions}` counts (when requested)                 |
| `next_continuation_token`    | integer or null | Token for the next page                                          |
| `has_more`                   | boolean         | Whether more commits exist                                       |

### Get Commit Diff

Get the raw diff for a specific commit.

|                |                                                  |
| -------------- | ------------------------------------------------ |
| **Method**     | `GET`                                            |
| **Path**       | `/v1/{organization}/tool/repo/commit/{sha}/diff` |
| **Rate Limit** | 60 requests/min                                  |

**Response**: Raw diff text (string).

## Files and Directories

### List Directory

List the contents of a directory in the repository.

|                |                                                           |
| -------------- | --------------------------------------------------------- |
| **Method**     | `GET`                                                     |
| **Path**       | `/v1/{organization}/tool/repo/directory/{directory_path}` |
| **Rate Limit** | 60 requests/min                                           |

**Query Parameters**

| Parameter                  | Type    | Default  | Description                             |
| -------------------------- | ------- | -------- | --------------------------------------- |
| `ref`                      | string  | `"main"` | Branch name or commit SHA               |
| `include_last_commit_info` | boolean | false    | Include last commit info for each entry |

**Response**

| Field                                  | Type           | Description                                                       |
| -------------------------------------- | -------------- | ----------------------------------------------------------------- |
| `directory_entries`                    | array          | List of directory entry objects                                   |
| `directory_entries[].type`             | string         | `"file"` or `"directory"`                                         |
| `directory_entries[].name`             | string         | Entry name                                                        |
| `directory_entries[].size`             | integer        | Size in bytes                                                     |
| `directory_entries[].last_commit_info` | object or null | `{commit_sha, commit_message, commit_timestamp}` (when requested) |

### Get Files (Batch)

Retrieve metadata and base64-encoded content for up to 5 files in a single request.

|                |                                     |
| -------------- | ----------------------------------- |
| **Method**     | `GET`                               |
| **Path**       | `/v1/{organization}/tool/repo/file` |
| **Rate Limit** | 60 requests/min                     |

**Query Parameters**

| Parameter    | Type             | Default  | Description                |
| ------------ | ---------------- | -------- | -------------------------- |
| `ref`        | string           | `"main"` | Branch name or commit SHA  |
| `file_paths` | array of strings | -        | 1-5 file paths to retrieve |

**Response**

| Field                             | Type           | Description                                      |
| --------------------------------- | -------------- | ------------------------------------------------ |
| `file_entries`                    | array          | List of file entry objects                       |
| `file_entries[].path`             | string         | File path                                        |
| `file_entries[].size`             | integer        | Size in bytes                                    |
| `file_entries[].content`          | string or null | Base64-encoded file content                      |
| `file_entries[].last_commit_info` | object         | `{commit_sha, commit_message, commit_timestamp}` |

### Get File Content

Download the raw content of a single file.

|                |                                                 |
| -------------- | ----------------------------------------------- |
| **Method**     | `GET`                                           |
| **Path**       | `/v1/{organization}/tool/repo/file/{file_path}` |
| **Rate Limit** | 50 requests/min                                 |

**Query Parameters**

| Parameter | Type   | Default  | Description               |
| --------- | ------ | -------- | ------------------------- |
| `ref`     | string | `"main"` | Branch name or commit SHA |

**Response**: Raw binary file content (streaming).

## Related

* Classic API → [Tools](https://docs.amigo.ai/developer-guide/classic-api/core-api/tools)
* Classic API → [Users](https://docs.amigo.ai/developer-guide/classic-api/core-api/users)
* Getting Started → [Authentication](https://docs.amigo.ai/developer-guide/getting-started/authentication)
* Permissions → [Role-Based Permissions](https://docs.amigo.ai/developer-guide/classic-api/permissions/role-based-permissions)
