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

# Create

### Create mutation

For create mutations, the request body is a `CreateMutationRequest` object with the following shape:

```typescript CreateMutationRequest theme={null}
 {
  kind: "create";
  sync_id: string;
  collection_id: string;
  data: PartialRecord[];
  await_consumer_ids?: string[];
  await_consumers_timeout?: number;
}
```

#### Parameters

<ParamField path="sync_id" type="string" required>
  The ID of the sync that the mutations should apply to.
</ParamField>

<ParamField path="collection_id" type="string" required>
  The ID of the collection that the mutations should apply to.
</ParamField>

<ParamField path="records" type="array" required>
  A list of one or more `PartialRecord` objects.
</ParamField>

<ParamField path="await_consumer_ids" type="array">
  A list of one or more consumer IDs. See [await consumers](#awaiting-consumers) below.
</ParamField>

<ParamField path="await_consumers_timeout" type="integer">
  The number of milliseconds to wait for consumers to finish processing a mutation. Defaults to `30000` (30 seconds). See [await consumers](#awaiting-consumers) below.
</ParamField>

### Response

If the mutation succeeds, Sequin will return a JSON object with a `records` property containing each [record](/core-concepts#records):

```json 200 OK theme={null}
{
  "records": [
    {
      "sync_id": "70a313f8-7c94-43d4-8d0c-5659a52de5c4",
      "collection_id" : "salesforce:task",
      "upstream_id": "0018b000021BldZAAS",
      "upstream_updated_at": "2024-11-10T18:39:00.070453Z",
      "data": {
        "activity_date": "2023-09-12",
        "description" : "task description [ ... ] ",
        // ...
      },
      "deleted": false,
      // ...
    }
  ]
 }
```

If the mutation fails due to a validation error, Sequin will return a `400 Bad Request` response with an error message:

```json 400 Bad Request theme={null}
{
  "error": "Error: Salesforce validation error: `Invalid email`",
  "docs": [ ... ]
}
```

If the mutation fails due to the upstream API timing out, Sequin will return a `504 Gateway Timeout` response with an error message:

```json 504 Gateway Timeout theme={null}
{
  "error": "Error: Salesforce API timed out",
  "docs": [ ... ]
}
```

### Examples

Create a single record:

```bash theme={null}
curl -X POST \
  https://api.sequin.io/v1/mutations/run \
  -H 'content-type: application/json' \
  -H 'authorization: Bearer {token}' \
  -d '{
        "kind": "create",
        "sync_id": "my-sync-id",
        "collection_id": "salesforce:contact",
        "records": [
          {
            "data": {
              "FirstName": "Paul",
              "LastName": "Atreides",
              "Email": "paul@arrakis.org"
            }
          }
        ]
      }'
```

Create multiple records:

```bash theme={null}
curl -X POST \
  https://api.sequin.io/v1/mutations/run \
  -H 'content-type: application/json' \
  -H 'authorization: Bearer {token}' \
  -d '{
        "kind": "create",
        "sync_id": "my-sync-id",
        "collection_id": "salesforce:contact",
        "records": [
          {
            "data": {
              "FirstName": "Paul",
              "LastName": "Atreides",
              "Email": "paul@arrakis.org"
            }
          },
          {
            "data": {
              "FirstName": "Duncan",
              "LastName": "Idaho",
              "Email": "duncan@arrakis.org"
            }
          }
        ]
      }'
```
