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

# Adding Data

### Add Data to a Bloc

Adds a new record to a Blocworx bloc.

<mark style="color:green;">`POST`</mark> `https://example.mydomain.com/api/add-data`

***

### Request Body

<table><thead><tr><th width="179.25390625">Name</th><th width="118.99609375">Type</th><th>Description</th></tr></thead><tbody><tr><td>scanStationID<mark style="color:red;">*</mark></td><td>string</td><td>The bloc ID to add data to. This may be a UUID depending on your instance.</td></tr><tr><td>jobID</td><td>string</td><td>The module ID associated with the bloc. This may be required depending on your instance or workflow.</td></tr><tr><td>dataToAdd<mark style="color:red;">*</mark></td><td>string</td><td>A JSON-encoded string containing the field slugs and values to add. Example: <code>"{\"field_1\":\"Test\",\"field_2\":\"123\"}"</code></td></tr></tbody></table>

***

### Request Notes

* `dataToAdd` should be sent as a **JSON string**
* This endpoint supports file-related workflows, so some clients may also use `multipart/form-data`
* For text-only submissions, raw JSON requests are supported

***

### 200 Success Response

```json
{
  "returnedStationID": 123456,
  "autogenerateReplacements": []
}
```

#### Response Notes

* `returnedStationID` is the **created data entry ID**
* `autogenerateReplacements` contains any auto-generated replacement values produced by the submission flow

***

### Error Responses

#### 403 Forbidden

```json
{
  "error": "You do not have permission to add or edit data on this form."
}
```

#### 400 Bad Request

```json
{
  "error": "Error message"
}
```

> In the current implementation, some 400 responses may also include debug fields such as `line`, `file`, and `trace`.

***

### Example Requests

#### JSON Request

```bash
curl --request POST 'https://example.mydomain.com/api/add-data' \
  --header 'Authorization: Bearer [AUTHTOKEN]' \
  --header 'Content-Type: application/json' \
  --data '{
    "scanStationID": "a1489634-4009-4cc0-8a65-9965f5a1bea7",
    "jobID": "a148961d-236f-4b7e-9ac4-bfc9b729b0d6",
    "dataToAdd": "{\"field_number_1\":\"ADD_TEST\",\"field_number_2\":\"123\",\"radio_name\":\"1\"}"
  }'
```

#### JavaScript

```javascript
fetch('https://example.mydomain.com/api/add-data', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer [AUTHTOKEN]',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    scanStationID: 'a1489634-4009-4cc0-8a65-9965f5a1bea7',
    jobID: 'a148961d-236f-4b7e-9ac4-bfc9b729b0d6',
    dataToAdd: JSON.stringify({
      field_number_1: 'ADD_TEST',
      field_number_2: '123',
      radio_name: '1'
    })
  })
})
.then(res => res.json())
.then(data => console.log(data));
```

#### Python

```python
import requests
import json

url = "https://example.mydomain.com/api/add-data"

payload = {
    "scanStationID": "a1489634-4009-4cc0-8a65-9965f5a1bea7",
    "jobID": "a148961d-236f-4b7e-9ac4-bfc9b729b0d6",
    "dataToAdd": json.dumps({
        "field_number_1": "ADD_TEST",
        "field_number_2": "123",
        "radio_name": "1"
    })
}

headers = {
    "Authorization": "Bearer [AUTHTOKEN]",
    "Content-Type": "application/json"
}

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


---

# 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, and the optional `goal` query parameter:

```
GET https://manual.blocworx.com/blocworx-api/reference/api-reference/adding-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
