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

# Bulk Upsert Records

Bulk upsert multiple records for a requested object in a single API call. This API is useful when you need to insert or update multiple records efficiently, reducing the number of API calls required.

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication, [click here](https://app.superleap.com/settings/apiAccess) to generate one
</ParamField>

<ParamField header="Content-Type" type="string" default="application/json" required>
  application/json
</ParamField>

### Path Parameters

<ParamField path="object_slug" type="string" required>
  The slug identifier for the object type you want to filter (e.g., "lead", "user", "opportunity")
</ParamField>

### Example Request

```bash theme={null}
curl --location 'https://app.superleap.dev/api/v1/org/objects/lead/record/bulk_upsert' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer OGEWZMJJMTGTNZEYZS0ZYTG3LTLKMMETY2I3MDDJNJKXMMM4' \
--data-raw '{
    "values": [
        {
            "name": "testAdmin",
            "email": "test@gmail.com"
        },
        {
            "id": "g1koYv_2lLKYVan",
            "name": "testSteve"
        }
    ]
}'
```

### Example

#### Request

```bash theme={null}
curl --location 'https://app.superleap.dev/api/v1/org/objects/lead/record/bulk_upsert' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer OGEWZMJJMTGTNZEYZS0ZYTG3LTLKMMETY2I3MDDJNJKXMMM4' \
--data-raw '{
    "values": [
        {
            "name": "testAdmin",
            "email": "test@gmail.com"
        },
        {
            "id": "g1koYv_2lLKYVan",
            "name": "testSteve"
        }
    ]
}'
```

#### Response 200 OK

```json theme={null}
{
    "success": true,
    "data": {
        "records_created": 1,
        "records_updated": 1,
        "failed_records": null,
        "created_records": [
            {
                "action": "CREATED",
                "created_at": 1753948409620,
                "created_by": "g1koYv_BkJ851eS",
                "email": "test@gmail.com",
                "id": "g1koYv_NmlNtQT1",
                "multiselect_1": [
                    "op3"
                ],
                "name": "testAdmin",
                "object_id": "g1koYv_EAobj2SH",
                "org_id": "g1koYv",
                "owner": "g1koYv_BkJ851eS",
                "search_field": "testAdmin",
                "system_created_at": 1753948409624,
                "updated_at": 1753948409620,
                "updated_by": "g1koYv_BkJ851eS"
            }
        ],
        "updated_records": [
            {
                "action": "UPDATED",
                "id": "g1koYv_2lLKYVan",
                "name": "testSteve",
                "object_id": "g1koYv_EAobj2SH",
                "org_id": "g1koYv",
                "search_field": "testSteve",
                "updated_at": 1753948409668,
                "updated_by": "g1koYv_BkJ851eS"
            }
        ],
        "records": [
            {
                "action": "CREATED",
                "created_at": 1753948409620,
                "created_by": "g1koYv_BkJ851eS",
                "email": "test@gmail.com",
                "id": "g1koYv_NmlNtQT1",
                "multiselect_1": [
                    "op3"
                ],
                "name": "testAdmin",
                "object_id": "g1koYv_EAobj2SH",
                "org_id": "g1koYv",
                "owner": "g1koYv_BkJ851eS",
                "search_field": "testAdmin",
                "system_created_at": 1753948409624,
                "updated_at": 1753948409620,
                "updated_by": "g1koYv_BkJ851eS"
            },
            {
                "action": "UPDATED",
                "id": "g1koYv_2lLKYVan",
                "name": "testSteve",
                "object_id": "g1koYv_EAobj2SH",
                "org_id": "g1koYv",
                "search_field": "testSteve",
                "updated_at": 1753948409668,
                "updated_by": "g1koYv_BkJ851eS"
            }
        ]
    }
}
```

#### Request for Failure Scenario

This example demonstrates how the API handles validation errors when the input data is not in the correct format

```bash theme={null}
curl --location 'https://app.superleap.dev/api/v1/org/objects/lead/record/bulk_upsert' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer OGEWZMJJMTGTNZEYZS0ZYTG3LTLKMMETY2I3MDDJNJKXMMM4' \
--data-raw '{
    "values": [
        {
            "name": "testssse",
            "email": "test@gmail.com"
        },
        {
            "id": "OAASbQ_Ph9vneRS",
            "name": "testsssdfsdfse"
        }
    ]
}'
```

#### Response 200 OK

Failures are returned in the response, allowing you to handle them appropriately.

```json theme={null}
{
    "success": true,
    "data": {
        "records_created": 1,
        "records_updated": 0,
        "failed_records": [
            {
                "action": "FAILED",
                "error_message": "invalid id detected : OAASbQ_Ph9vneRS",
                "id": "OAASbQ_Ph9vneRS",
                "name": "testsssdfsdfse"
            }
        ],
        "created_records": [
            {
                "action": "CREATED",
                "created_at": 1753948287965,
                "created_by": "g1koYv_BkJ851eS",
                "email": "test@gmail.com",
                "id": "g1koYv_y3msyauq",
                "multiselect_1": [
                    "op3"
                ],
                "name": "testssse",
                "object_id": "g1koYv_EAobj2SH",
                "org_id": "g1koYv",
                "owner": "g1koYv_BkJ851eS",
                "search_field": "testssse",
                "system_created_at": 1753948287970,
                "updated_at": 1753948287965,
                "updated_by": "g1koYv_BkJ851eS"
            }
        ],
        "updated_records": null,
        "records": [
            {
                "action": "CREATED",
                "created_at": 1753948287965,
                "created_by": "g1koYv_BkJ851eS",
                "email": "test@gmail.com",
                "id": "g1koYv_y3msyauq",
                "multiselect_1": [
                    "op3"
                ],
                "name": "testssse",
                "object_id": "g1koYv_EAobj2SH",
                "org_id": "g1koYv",
                "owner": "g1koYv_BkJ851eS",
                "search_field": "testssse",
                "system_created_at": 1753948287970,
                "updated_at": 1753948287965,
                "updated_by": "g1koYv_BkJ851eS"
            },
            {
                "action": "FAILED",
                "error_message": "invalid id detected : OAASbQ_Ph9vneRS",
                "id": "OAASbQ_Ph9vneRS",
                "name": "testsssdfsdfse"
            }
        ]
    }
}
```
