---
title: "Batch-import objects into a space"
---

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

# Batch-import objects into a space

Path: CloudRaker Workspace API › Data Objects

`POST /spaces/{spaceId}/objects/{definitionId}/batch`

Bulk-imports up to 200 objects for a definition within a space (used by the extraction-import feed). Authorization: requires `space:contribute` on `:spaceId` — lacking it gives **403** (no `space:read` → 404). Body: `{ objects: [{ _id?, data, fieldMeta?, provenance?, origin? }] }` (1–200 rows). A caller-chosen `_id` makes the row idempotent — an existing/repeated id is `skipped`; a non-empty `provenance` (per-field citation pointers) seeds a pending review per grounded field. A row `origin` accepts only `{ actionRunId }`; any supplied `playbookRunId` is ignored because playbook provenance can only be added during playbook execution. Web imports always stay **pending**: a top-level `reviewStatus` cannot approve an import. **Always returns 200** (never a partial-failure status) with `{ results, created, skipped, failed }`; each result is `{ index, status: created|skipped|duplicate|invalid, _id?, issues? }`.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `spaceId` (`batchCreateObjects.path.spaceId`; string, required)
- `definitionId` (`batchCreateObjects.path.definitionId`; string, required)

## Request body

_Required._

- `objects` (`batchCreateObjects.objects`; array<object>, required)
  - `data` (`batchCreateObjects.objects.data`; map<unknown>, required)
  - `_id` (`batchCreateObjects.objects._id`; string, optional) — Caller-chosen id. A repeat of an existing id makes the row `skipped`.
  - `fieldMeta` (`batchCreateObjects.objects.fieldMeta`; map<map<unknown>>, optional) — Per-field metadata keyed by field key. Only `source` and `locked` are accepted.
  - `provenance` (`batchCreateObjects.objects.provenance`; map<array<map<unknown>>>, optional) — A non-empty map seeds a pending review per grounded field.
  - `origin` (`batchCreateObjects.objects.origin`; object, optional) — Only `actionRunId` is accepted; a supplied `playbookRunId` is dropped.
    - `actionRunId` (`batchCreateObjects.objects.origin.actionRunId`; string, optional)

## Example request

```json
{
  "objects": [
    {
      "_id": "string",
      "data": {
        "property1": null,
        "property2": null
      },
      "fieldMeta": {
        "property1": {
          "property1": null,
          "property2": null
        },
        "property2": {
          "property1": null,
          "property2": null
        }
      },
      "provenance": {
        "property1": [
          {
            "property1": null,
            "property2": null
          }
        ],
        "property2": [
          {
            "property1": null,
            "property2": null
          }
        ]
      },
      "origin": {
        "actionRunId": "string"
      }
    }
  ]
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/spaces/<spaceId>/objects/<definitionId>/batch' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "objects": [
    {
      "_id": "string",
      "data": {
        "property1": null,
        "property2": null
      },
      "fieldMeta": {
        "property1": {
          "property1": null,
          "property2": null
        },
        "property2": {
          "property1": null,
          "property2": null
        }
      },
      "provenance": {
        "property1": [
          {
            "property1": null,
            "property2": null
          }
        ],
        "property2": [
          {
            "property1": null,
            "property2": null
          }
        ]
      },
      "origin": {
        "actionRunId": "string"
      }
    }
  ]
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/spaces/<spaceId>/objects/<definitionId>/batch';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    objects: [
      {
        _id: 'string',
        data: {property1: null, property2: null},
        fieldMeta: {
          property1: {property1: null, property2: null},
          property2: {property1: null, property2: null}
        },
        provenance: {
          property1: [{property1: null, property2: null}],
          property2: [{property1: null, property2: null}]
        },
        origin: {actionRunId: 'string'}
      }
    ]
  })
};

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

### Python

```python
import requests

url = "https://api.cloudraker.com/spaces/<spaceId>/objects/<definitionId>/batch"

payload = { "objects": [
        {
            "_id": "string",
            "data": {
                "property1": None,
                "property2": None
            },
            "fieldMeta": {
                "property1": {
                    "property1": None,
                    "property2": None
                },
                "property2": {
                    "property1": None,
                    "property2": None
                }
            },
            "provenance": {
                "property1": [
                    {
                        "property1": None,
                        "property2": None
                    }
                ],
                "property2": [
                    {
                        "property1": None,
                        "property2": None
                    }
                ]
            },
            "origin": { "actionRunId": "string" }
        }
    ] }
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 200

Per-row outcome.

#### Example

```json
{
  "results": [
    {
      "index": 0,
      "status": "created",
      "_id": "string",
      "fieldKey": "string",
      "issues": [
        {
          "fieldKey": "string",
          "message": "string"
        }
      ]
    }
  ],
  "created": 0,
  "skipped": 0,
  "failed": 0
}
```

- `results` (`batchCreateObjects.response.200.results`; array<object>, required)
  - `index` (`batchCreateObjects.response.200.results.index`; number, required)
  - `status` (`batchCreateObjects.response.200.results.status`; string, required)
    - one of `"created"`, `"skipped"`, `"duplicate"`, `"invalid"`
  - `_id` (`batchCreateObjects.response.200.results._id`; string, optional)
  - `fieldKey` (`batchCreateObjects.response.200.results.fieldKey`; string, optional)
  - `issues` (`batchCreateObjects.response.200.results.issues`; array<object>, optional)
    - `fieldKey` (`batchCreateObjects.response.200.results.issues.fieldKey`; string, required)
    - `message` (`batchCreateObjects.response.200.results.issues.message`; string, required)
- `created` (`batchCreateObjects.response.200.created`; number, required)
- `skipped` (`batchCreateObjects.response.200.skipped`; number, required)
- `failed` (`batchCreateObjects.response.200.failed`; number, required)

### 403

Missing `space:contribute`.


Source: https://docs.cloudraker.com/workspace/api/data-objects/batch-create-objects/index.md
