---
title: "createRepoExtensionFile"
---

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

# createRepoExtensionFile

Path: Forge API › extensions

`POST /repos/{repo_id}/branches/{branch}/extensions/{name}/files`

Add a file to an extension. Each commit that changes it publishes a build from index.ts, which defines the extension's tools and imports its other modules (.ts, .tsx, .js, .jsx) and the npm packages its package.json declares; package.json declares @buildr/sdk too. ui/web/index.html and the files under ui/web/ make its UI, a module directly under ui/mcp/ makes each MCP UI it declares, and files under tests/ hold its tests and their fixtures. A binary file, such as a WebAssembly module its UI imports, takes {"path":…,"attachment_blob_id":…} for an uploaded attachment blob in place of "content", up to 16 MiB.

## Path parameters

- `repo_id` (`createRepoExtensionFile.path.repo_id`; string, required)
  - pattern: `^repo_[0-7][0-9a-hjkmnp-tv-z]{25}$`
- `branch` (`createRepoExtensionFile.path.branch`; string, required)
  - minLength: `1`
- `name` (`createRepoExtensionFile.path.name`; string, required)
  - maxLength: `64` · pattern: `^[a-z0-9]+(?:-[a-z0-9]+)*$`

## Request body

_Required._

- `path` (`createRepoExtensionFile.path`; string, required)
  - maxLength: `256` · pattern: `^(?:[A-Za-z0-9_][A-Za-z0-9._-]*\/)*[A-Za-z0-9_][A-Za-z0-9._-]*$`
- `content` (`createRepoExtensionFile.content`; string, optional)
- `attachment_blob_id` (`createRepoExtensionFile.attachment_blob_id`; string, optional)
  - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`

## Example request

```json
{
  "path": "string",
  "content": "string",
  "attachment_blob_id": "string"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/repos/<repo_id>/branches/<branch>/extensions/<name>/files' \
  --header 'Content-Type: application/json' \
  --data '
{
  "path": "string",
  "content": "string",
  "attachment_blob_id": "string"
}
'
```

### TypeScript

```typescript
const url = '<base-url>/repos/<repo_id>/branches/<branch>/extensions/<name>/files';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({path: 'string', content: 'string', attachment_blob_id: 'string'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/repos/<repo_id>/branches/<branch>/extensions/<name>/files"

payload = {
    "path": "string",
    "content": "string",
    "attachment_blob_id": "string"
}
headers = {"Content-Type": "application/json"}

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

print(response.text)
```

## Responses

### 201

ExtensionFile

#### Example

```json
{
  "id": "string",
  "extension_id": "string",
  "path": "string",
  "content": "string",
  "attachment_blob_id": "string",
  "formatted_content": "string",
  "formatting_pending": true
}
```

- `id` (`createRepoExtensionFile.response.201.id`; string, required)
  - pattern: `^extension_file_[0-7][0-9a-hjkmnp-tv-z]{25}$`
- `extension_id` (`createRepoExtensionFile.response.201.extension_id`; string, required)
  - pattern: `^extension_[0-7][0-9a-hjkmnp-tv-z]{25}$`
- `path` (`createRepoExtensionFile.response.201.path`; string, required)
  - maxLength: `256` · pattern: `^(?:[A-Za-z0-9_][A-Za-z0-9._-]*\/)*[A-Za-z0-9_][A-Za-z0-9._-]*$`
- `content` (`createRepoExtensionFile.response.201.content`; string, required)
- `attachment_blob_id` (`createRepoExtensionFile.response.201.attachment_blob_id`; any of, required)
  - any of the following: `TypeId`, `null`
- `formatted_content` (`createRepoExtensionFile.response.201.formatted_content`; any of, required) — The file formatted with Prettier for reading, when that differs from `content`. Forge formats a file shortly after it's written, so this is null until then, and stays null when the file is already formatted, isn't TypeScript, JavaScript or JSON, is over 256 KiB, or doesn't parse. Writes never take it, and builds read only `content`, so edit from `content`.
  - any of the following: `string`, `null`
- `formatting_pending` (`createRepoExtensionFile.response.201.formatting_pending`; boolean, required) — Whether Forge is still formatting the file: read it again shortly for `formatted_content`. False once it's formatted, or when Forge doesn't format it.

### 400

InvalidRequest | RequestBodyTooDeep

#### Example

```json
{
  "_tag": "InvalidRequest",
  "part": "path",
  "issues": [
    {
      "path": [
        "string"
      ],
      "message": "string"
    }
  ]
}
```

Any of the following:

- `InvalidRequestEncoded`
  - `_tag` (`InvalidRequestEncoded._tag`; string, required)
    - one of `"InvalidRequest"`
  - `part` (`InvalidRequestEncoded.part`; string, required)
    - one of `"path"`, `"query"`, `"headers"`, `"body"`
  - `issues` (`InvalidRequestEncoded.issues`; array of object, required)
    - `path` (`InvalidRequestEncoded.issues.path`; array\<any of\>, required)
      - any of the following: `string`, `integer`
    - `message` (`InvalidRequestEncoded.issues.message`; string, required)
- `RequestBodyTooDeepEncoded`
  - `_tag` (`RequestBodyTooDeepEncoded._tag`; string, required)
    - one of `"RequestBodyTooDeep"`
  - `max_depth` (`RequestBodyTooDeepEncoded.max_depth`; integer, required)
    - maximum: `9007199254740991` · minimum: `-9007199254740991`

### 401

InvalidCredentials

#### Example

```json
{
  "_tag": "InvalidCredentials"
}
```

- `_tag` (`createRepoExtensionFile.response.401._tag`; string, required)
  - one of `"InvalidCredentials"`

### 403

Forbidden | ForbiddenOrigin | RequiresPersonalSession | RunBranchRequired

#### Example

```json
{
  "_tag": "Forbidden",
  "message": "string"
}
```

Any of the following:

- `ForbiddenEncoded`
  - `_tag` (`ForbiddenEncoded._tag`; string, required)
    - one of `"Forbidden"`
  - `message` (`ForbiddenEncoded.message`; string, required)
- `ForbiddenOriginEncoded`
  - `_tag` (`ForbiddenOriginEncoded._tag`; string, required)
    - one of `"ForbiddenOrigin"`
- `RequiresPersonalSessionEncoded`
  - `_tag` (`RequiresPersonalSessionEncoded._tag`; string, required)
    - one of `"RequiresPersonalSession"`
- `RunBranchRequiredEncoded`
  - `_tag` (`RunBranchRequiredEncoded._tag`; string, required)
    - one of `"RunBranchRequired"`
  - `branch` (`RunBranchRequiredEncoded.branch`; string, required)
    - minLength: `1`
  - `message` (`RunBranchRequiredEncoded.message`; string, required)

### 404

BranchNotFound | ExtensionNotFound | RepoNotFound

#### Example

```json
{
  "_tag": "BranchNotFound",
  "branch": "string"
}
```

Any of the following:

- `BranchNotFoundEncoded`
  - `_tag` (`BranchNotFoundEncoded._tag`; string, required)
    - one of `"BranchNotFound"`
  - `branch` (`BranchNotFoundEncoded.branch`; string, required)
    - minLength: `1`
- `ExtensionNotFoundEncoded`
  - `_tag` (`ExtensionNotFoundEncoded._tag`; string, required)
    - one of `"ExtensionNotFound"`
  - `extension_name` (`ExtensionNotFoundEncoded.extension_name`; string, required)
    - minLength: `1`
- `RepoNotFoundEncoded`
  - `_tag` (`RepoNotFoundEncoded._tag`; string, required)
    - one of `"RepoNotFound"`

### 409

ExtensionFileBlobNotUploaded | RepoArchived

#### Example

```json
{
  "_tag": "ExtensionFileBlobNotUploaded",
  "path": "string",
  "attachment_blob_id": "string"
}
```

Any of the following:

- `ExtensionFileBlobNotUploadedEncoded`
  - `_tag` (`ExtensionFileBlobNotUploadedEncoded._tag`; string, required)
    - one of `"ExtensionFileBlobNotUploaded"`
  - `path` (`ExtensionFileBlobNotUploadedEncoded.path`; string, required)
    - minLength: `1`
  - `attachment_blob_id` (`ExtensionFileBlobNotUploadedEncoded.attachment_blob_id`; string, required)
    - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
- `RepoArchivedEncoded`
  - `_tag` (`RepoArchivedEncoded._tag`; string, required)
    - one of `"RepoArchived"`

### 413

ExtensionFileTooLarge | WriteTooLarge | RequestBodyTooLarge

#### Example

```json
{
  "_tag": "ExtensionFileTooLarge",
  "path": "string",
  "bytes": -9007199254740991,
  "max_bytes": -9007199254740991
}
```

Any of the following:

- `ExtensionFileTooLargeEncoded`
  - `_tag` (`ExtensionFileTooLargeEncoded._tag`; string, required)
    - one of `"ExtensionFileTooLarge"`
  - `path` (`ExtensionFileTooLargeEncoded.path`; string, required)
    - minLength: `1`
  - `bytes` (`ExtensionFileTooLargeEncoded.bytes`; integer, required)
    - maximum: `9007199254740991` · minimum: `-9007199254740991`
  - `max_bytes` (`ExtensionFileTooLargeEncoded.max_bytes`; integer, required)
    - maximum: `9007199254740991` · minimum: `-9007199254740991`
- `WriteTooLargeEncoded`
  - `_tag` (`WriteTooLargeEncoded._tag`; string, required)
    - one of `"WriteTooLarge"`
  - `message` (`WriteTooLargeEncoded.message`; string, required)
- `RequestBodyTooLargeEncoded`
  - `_tag` (`RequestBodyTooLargeEncoded._tag`; string, required)
    - one of `"RequestBodyTooLarge"`
  - `max_bytes` (`RequestBodyTooLargeEncoded.max_bytes`; integer, required)
    - maximum: `9007199254740991` · minimum: `-9007199254740991`

### 422

WriteRefused

#### Example

```json
{
  "_tag": "WriteRefused",
  "violations": [
    {
      "kind": "formula",
      "model": "string",
      "field": "string",
      "reason": "string",
      "record_ids": [
        "string"
      ]
    }
  ]
}
```

- `_tag` (`createRepoExtensionFile.response.422._tag`; string, required)
  - one of `"WriteRefused"`
- `violations` (`createRepoExtensionFile.response.422.violations`; array of Violation, required)
  - every option has:
    - `field` (`<option>.field`; string, required)
      - minLength: `1`
  - any of the following, each adding:
    - `object` (`createRepoExtensionFile.response.422.violations.1`)
      - `kind` (`createRepoExtensionFile.response.422.violations.1.kind`; any of, required)
        - any of the following:
          - `string`: one of `"formula"`
      - `model` (`createRepoExtensionFile.response.422.violations.1.model`; string, required)
        - minLength: `1`
      - `reason` (`createRepoExtensionFile.response.422.violations.1.reason`; string, required)
        - minLength: `1`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.1.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.2`)
      - `kind` (`createRepoExtensionFile.response.422.violations.2.kind`; any of, required)
        - any of the following:
          - `string`: one of `"custom_field"`
      - `model` (`createRepoExtensionFile.response.422.violations.2.model`; string, required)
        - minLength: `1`
      - `reason` (`createRepoExtensionFile.response.422.violations.2.reason`; string, required)
        - minLength: `1`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.2.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.3`)
      - `kind` (`createRepoExtensionFile.response.422.violations.3.kind`; any of, required)
        - any of the following:
          - `string`: one of `"uncarried_value"`
      - `model` (`createRepoExtensionFile.response.422.violations.3.model`; string, required)
        - minLength: `1`
      - `record_id` (`createRepoExtensionFile.response.422.violations.3.record_id`; string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
      - `written_by` (`createRepoExtensionFile.response.422.violations.3.written_by`; string, required)
        - one of `"ours"`, `"theirs"`
      - `value` (`createRepoExtensionFile.response.422.violations.3.value`; unknown, required)
      - `reason` (`createRepoExtensionFile.response.422.violations.3.reason`; string, required)
        - minLength: `1`
    - `object` (`createRepoExtensionFile.response.422.violations.4`)
      - `kind` (`createRepoExtensionFile.response.422.violations.4.kind`; any of, required)
        - any of the following:
          - `string`: one of `"record_reference"`
      - `model` (`createRepoExtensionFile.response.422.violations.4.model`; string, required)
        - minLength: `1`
      - `record_id` (`createRepoExtensionFile.response.422.violations.4.record_id`; string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
      - `referenced_model` (`createRepoExtensionFile.response.422.violations.4.referenced_model`; any of, required)
        - any of the following: `string`, `null`
      - `referenced_record_id` (`createRepoExtensionFile.response.422.violations.4.referenced_record_id`; string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.5`)
      - `kind` (`createRepoExtensionFile.response.422.violations.5.kind`; any of, required)
        - any of the following:
          - `string`: one of `"reference_target"`
      - `model` (`createRepoExtensionFile.response.422.violations.5.model`; string, required)
        - minLength: `1`
      - `target_model` (`createRepoExtensionFile.response.422.violations.5.target_model`; any of, required)
        - any of the following: `string`, `null`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.5.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.6`)
      - `kind` (`createRepoExtensionFile.response.422.violations.6.kind`; any of, required)
        - any of the following:
          - `string`: one of `"reference_field_target"`
      - `model` (`createRepoExtensionFile.response.422.violations.6.model`; string, required)
        - minLength: `1`
      - `target_model` (`createRepoExtensionFile.response.422.violations.6.target_model`; any of, required)
        - any of the following: `string`, `null`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.6.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.7`)
      - `kind` (`createRepoExtensionFile.response.422.violations.7.kind`; any of, required)
        - any of the following:
          - `string`: one of `"unique"`
      - `model` (`createRepoExtensionFile.response.422.violations.7.model`; string, required)
        - minLength: `1`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.7.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.8`)
      - `kind` (`createRepoExtensionFile.response.422.violations.8.kind`; any of, required)
        - any of the following:
          - `string`: one of `"required"`
      - `model` (`createRepoExtensionFile.response.422.violations.8.model`; string, required)
        - minLength: `1`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.8.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.9`)
      - `kind` (`createRepoExtensionFile.response.422.violations.9.kind`; any of, required)
        - any of the following:
          - `string`: one of `"field_api_name"`
      - `model` (`createRepoExtensionFile.response.422.violations.9.model`; string, required)
        - minLength: `1`
      - `api_name` (`createRepoExtensionFile.response.422.violations.9.api_name`; string, required)
        - minLength: `1`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.9.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.10`)
      - `kind` (`createRepoExtensionFile.response.422.violations.10.kind`; any of, required)
        - any of the following:
          - `string`: one of `"model_api_name"`
      - `model` (`createRepoExtensionFile.response.422.violations.10.model`; string, required)
        - minLength: `1`
      - `api_name` (`createRepoExtensionFile.response.422.violations.10.api_name`; string, required)
        - minLength: `1`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.10.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.11`)
      - `kind` (`createRepoExtensionFile.response.422.violations.11.kind`; any of, required)
        - any of the following:
          - `string`: one of `"extension_name"`
      - `model` (`createRepoExtensionFile.response.422.violations.11.model`; string, required)
        - minLength: `1`
      - `name` (`createRepoExtensionFile.response.422.violations.11.name`; string, required)
        - minLength: `1`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.11.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.12`)
      - `kind` (`createRepoExtensionFile.response.422.violations.12.kind`; any of, required)
        - any of the following:
          - `string`: one of `"extension_peer"`
      - `model` (`createRepoExtensionFile.response.422.violations.12.model`; string, required)
        - minLength: `1`
      - `name` (`createRepoExtensionFile.response.422.violations.12.name`; string, required)
        - minLength: `1`
      - `version` (`createRepoExtensionFile.response.422.violations.12.version`; string, required)
        - minLength: `1`
      - `peer` (`createRepoExtensionFile.response.422.violations.12.peer`; string, required)
        - minLength: `1`
      - `range` (`createRepoExtensionFile.response.422.violations.12.range`; string, required)
        - minLength: `1`
      - `peer_version` (`createRepoExtensionFile.response.422.violations.12.peer_version`; any of, required)
        - any of the following: `string`, `null`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.12.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.13`)
      - `kind` (`createRepoExtensionFile.response.422.violations.13.kind`; any of, required)
        - any of the following:
          - `string`: one of `"attachment"`
      - `model` (`createRepoExtensionFile.response.422.violations.13.model`; string, required)
        - minLength: `1`
      - `record_id` (`createRepoExtensionFile.response.422.violations.13.record_id`; string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
      - `attachment_blob_id` (`createRepoExtensionFile.response.422.violations.13.attachment_blob_id`; string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.14`)
      - `kind` (`createRepoExtensionFile.response.422.violations.14.kind`; any of, required)
        - any of the following:
          - `string`: one of `"agent_skill"`
      - `model` (`createRepoExtensionFile.response.422.violations.14.model`; string, required)
        - minLength: `1`
      - `reason` (`createRepoExtensionFile.response.422.violations.14.reason`; string, required)
        - minLength: `1`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.14.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
    - `object` (`createRepoExtensionFile.response.422.violations.15`)
      - `kind` (`createRepoExtensionFile.response.422.violations.15.kind`; any of, required)
        - any of the following:
          - `string`: one of `"tag_state"`
      - `reason` (`createRepoExtensionFile.response.422.violations.15.reason`; string, required)
        - minLength: `1`
      - `record_ids` (`createRepoExtensionFile.response.422.violations.15.record_ids`; array of string, required)
        - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`

### 429

RateLimited

#### Example

```json
{
  "_tag": "RateLimited"
}
```

- `_tag` (`createRepoExtensionFile.response.429._tag`; string, required)
  - one of `"RateLimited"`

### 500

RepoFailure

#### Example

```json
{
  "_tag": "RepoFailure",
  "reason": "string"
}
```

- `_tag` (`createRepoExtensionFile.response.500._tag`; string, required)
  - one of `"RepoFailure"`
- `reason` (`createRepoExtensionFile.response.500.reason`; string, required)

### 503

AttachmentStorageUnavailable | RepoBusy | SessionUnavailable | RateLimitUnavailable

#### Example

```json
{
  "_tag": "AttachmentStorageUnavailable"
}
```

Any of the following:

- `AttachmentStorageUnavailableEncoded`
  - `_tag` (`AttachmentStorageUnavailableEncoded._tag`; string, required)
    - one of `"AttachmentStorageUnavailable"`
- `RepoBusyEncoded`
  - `_tag` (`RepoBusyEncoded._tag`; string, required)
    - one of `"RepoBusy"`
  - `message` (`RepoBusyEncoded.message`; string, required)
- `SessionUnavailableEncoded`
  - `_tag` (`SessionUnavailableEncoded._tag`; string, required)
    - one of `"SessionUnavailable"`
- `RateLimitUnavailableEncoded`
  - `_tag` (`RateLimitUnavailableEncoded._tag`; string, required)
    - one of `"RateLimitUnavailable"`


Source: https://buildrforge.com/docs/api/create-repo-extension-file/index.md
