> For the complete documentation index, see [llms.txt](https://docs.testvibe.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testvibe.com/testvibe-api/api-reference/files/write_file.md).

# write\_file

Create or overwrite a project file. The write takes effect on the **next** run or generation.

{% hint style="warning" %}
**The allowlist is strict.** Only paths under `Features/` or `Configurations/` are writable, no `..` segments, content ≤ 256 KB. Generated specs and template scaffolding are owned by the pipeline and can't be written. See [Files & configurations](/testvibe-api/core-concepts/files-and-configurations.md).
{% endhint %}

## Request

```
PUT /api/v1/ops/projects/{project}/files/content
```

| Parameter | In   | Type   | Required | Description                                            |
| --------- | ---- | ------ | -------- | ------------------------------------------------------ |
| `project` | path | string | yes      | The project's public id.                               |
| `path`    | body | string | yes      | The file path, e.g. `Configurations/Mobile.config.js`. |
| `content` | body | string | yes      | The full file content (writes are whole-file).         |

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X PUT -H "Authorization: Bearer $TESTVIBE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"path": "Configurations/Mobile.config.js", "content": "module.exports = { … };"}' \
  "$TESTVIBE_SERVER/api/v1/ops/projects/$PROJECT/files/content"
```

{% endtab %}

{% tab title="CLI" %}

```bash
testvibe files put Configurations/Mobile.config.js --file ./mobile.config.js
```

{% endtab %}

{% tab title="MCP" %}
Tool **`write_file`** — `{ "path": "Configurations/Mobile.config.js", "content": "…" }`.
{% endtab %}
{% endtabs %}

## Response

```json
{ "ok": true }
```

## Errors

| HTTP                  | When                                                                                        |
| --------------------- | ------------------------------------------------------------------------------------------- |
| `400 invalid_request` | Path missing, outside `Features/`/`Configurations/`, contains `..`, or content over 256 KB. |
| `404 not_found`       | No such project in this workspace.                                                          |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.testvibe.com/testvibe-api/api-reference/files/write_file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
