# Bulk

Allows you to create up to 1000 customers and related resources in a single request asynchronously. The organization will be notified by email when the operation is completed.

# Create Bulk Action

POST https://<org-uuid>.production.tratta.io/api/v1/bulk

# Parameters

This endpoint takes an array of customers with it's location and debt accounts data. You can also provide an array of parent debt accounts. If you want to nest your Debt Accounts under Parent Debt Accounts, make sure to add parent_external_id property to debt_accounts objects that corresponds to the external_id of any of the parent_debt_accounts provided. The other option is to signify parent accounts implicitly just by passing array of debt_accounts, where Parent Debt Account has external_id but parent_external_id is null.

Example

[
    {
        "customer": {
            "name": "Tremaine Abbott",
            "email": "tatum.marks@example.com",
            "external_id": "70b440dc-5283-3bd5-bb93-8dc599f2288f",
            "phone": "+1-489-899-2182",
            "date_of_birth": "1990-01-01",
            "ssn_last4": 9098,
            "address": {
                "name": "Dr. Pascale Purdy",
                "city": "East Ophelia",
                "postal_code": "00485-8914",
                "country": "Serbia",
                "is_primary": false,
                "line1": "2190 Streich Gateway\nEast Conor, OK 74977-6615",
                "line2": "Suite 420",
                "state": "Minnesota"
            },
            "metadata": {
                "pariatur": "ipsum",
                "ad": "perspiciatis",
                "culpa": "et",
                "rem": "libero"
            }
        },
        "location": {
            "name": "provident",
            "external_id": "rerum"
        },
        "parent_debt_accounts": [
            {
                "billing_type": [
                    "partial-payment"
                ],
                "external_account_number": "1rTg2nefvo8G",
                "balance": 0,
                "current_balance": 0,
                "external_id": "parent-external-id",
                "metadata": {
                    "sapiente": "aut",
                    "doloremque": "ut",
                    "quas": "a"
                }
            },
        ]
        "debt_accounts": [
            {
                "billing_type": [
                    "partial-payment"
                ],
                "external_account_number": "1rTg2nefvo8J",
                "balance": 100,
                "current_balance": 100,
                "external_id": "awfert",
                "metadata": {
                    "sapiente": "aut",
                    "doloremque": "ut",
                    "quas": "a"
                }
            },
            {
                "billing_type": [
                    "partial-payment"
                ],
                "external_account_number": "aCQb2a66LcaX",
                "balance": 100,
                "current_balance": 100,
                "parent_external_id": "parent-external-id",
                "external_id": "vel",
                "metadata": {
                    "et": "reprehenderit",
                    "quia": "quia",
                    "dolorem": "ut"
                }
            },
            {
                "billing_type": [
                    "partial-payment"
                ],
                "external_account_number": "EdvUmwjHoPVU",
                "balance": 100,
                "current_balance": 100,
                "external_id": "quia",
                "metadata": {
                    "repudiandae": "omnis",
                    "distinctio": "delectus",
                    "sunt": "quibusdam"
                }
            },
            {
                "billing_type": [
                    "partial-payment"
                ],
                "external_account_number": "Ii3WNP93ePKV",
                "balance": 100,
                "current_balance": 100,
                "external_id": "maiores",
                "metadata": {
                    "libero": "sit",
                    "sit": "enim",
                    "est": "ipsa"
                }
            },
            {
                "billing_type": [
                    "partial-payment"
                ],
                "external_account_number": "kqipYsoS2hdN",
                "balance": 100,
                "current_balance": 100,
                "external_id": "molestiae",
                "metadata": {
                    "aut": "laboriosam",
                    "velit": "ut",
                    "ut": "dolores"
                }
            }
        ]
    },
]

# Returns

{
    "data": {
        "bulk_id": string,
        "count": int,
        "status": string
    }
}

A bulk operation can be in 2 states pending and completed.

# Errors

Once a bulk action is created, you can get the errors in each row of the data passed.

GET https://<org-uuid>.production.tratta.io/api/v1/bulk/{id}/errors

# Returns

{
    "data": [
        {
            "id": 1,
            "payload": {
                "customer": {
                    "name": "Tremaine Abbott",
                    "email": "tatum.marks@example.com",
                    "phone": "+1-489-899-2182",
                    "address": {
                        "city": "East Ophelia",
                        "name": "Dr. Pascale Purdy",
                        "line1": "2190 Streich Gateway\nEast Conor, OK 74977-6615",
                        "line2": "Suite 420",
                        "state": "Minnesota",
                        "country": "Serbia",
                        "is_primary": false,
                        "postal_code": "00485-8914"
                    },
                    "metadata": {
                        "ad": "perspiciatis",
                        "rem": "libero",
                        "culpa": "et",
                        "pariatur": "ipsum"
                    },
                    "ssn_last4": 9098,
                    "external_id": "70b440dc-5283-3bd5-bb93-8dc599f2288f",
                    "date_of_birth": "1990-01-01"
                },
                "location": {
                    "name": "provident",
                    "external_id": "rerum"
                },
                "debt_accounts": [
                    {
                        "balance": 100,
                        "metadata": {
                            "quas": "a",
                            "sapiente": "aut",
                            "doloremque": "ut"
                        },
                        "external_id": "awfert",
                        "billing_type": [
                            "partial-payment"
                        ],
                        "current_balance": 100,
                        "external_account_number": "1rTg2nefvo8J"
                    },
                    {
                        "balance": 100,
                        "metadata": {
                            "et": "reprehenderit",
                            "quia": "quia",
                            "dolorem": "ut"
                        },
                        "external_id": "vel",
                        "billing_type": [
                            "partial-payment"
                        ],
                        "current_balance": 100,
                        "external_account_number": "aCQb2a66LcaX"
                    },
                    {
                        "balance": 100,
                        "metadata": {
                            "sunt": "quibusdam",
                            "distinctio": "delectus",
                            "repudiandae": "omnis"
                        },
                        "external_id": "quia",
                        "billing_type": [
                            "partial-payment"
                        ],
                        "current_balance": 100,
                        "external_account_number": "EdvUmwjHoPVU"
                    },
                    {
                        "balance": 100,
                        "metadata": {
                            "est": "ipsa",
                            "sit": "enim",
                            "libero": "sit"
                        },
                        "external_id": "maiores",
                        "billing_type": [
                            "partial-payment"
                        ],
                        "current_balance": 100,
                        "external_account_number": "Ii3WNP93ePKV"
                    },
                    {
                        "balance": 100,
                        "metadata": {
                            "ut": "dolores",
                            "aut": "laboriosam",
                            "velit": "ut"
                        },
                        "external_id": "molestiae",
                        "billing_type": [
                            "partial-payment"
                        ],
                        "current_balance": 100,
                        "external_account_number": "kqipYsoS2hdN"
                    }
                ]
            },
            "errors": {
                "customer": [],
                "location": [],
                "debt_accounts": [
                    {
                        "data": {
                            "balance": 100,
                            "metadata": {
                                "et": "reprehenderit",
                                "quia": "quia",
                                "dolorem": "ut"
                            },
                            "external_id": "vel",
                            "billing_type": [
                                "partial-payment"
                            ],
                            "current_balance": 100,
                            "external_account_number": "aCQb2a66LcaX"
                        },
                        "messages": {
                            "external_id": [
                                "The external id has already been taken."
                            ]
                        }
                    },
                    {
                        "data": {
                            "balance": 100,
                            "metadata": {
                                "sunt": "quibusdam",
                                "distinctio": "delectus",
                                "repudiandae": "omnis"
                            },
                            "external_id": "quia",
                            "billing_type": [
                                "partial-payment"
                            ],
                            "current_balance": 100,
                            "external_account_number": "EdvUmwjHoPVU"
                        },
                        "messages": {
                            "external_id": [
                                "The external id has already been taken."
                            ]
                        }
                    },
                    {
                        "data": {
                            "balance": 100,
                            "metadata": {
                                "est": "ipsa",
                                "sit": "enim",
                                "libero": "sit"
                            },
                            "external_id": "maiores",
                            "billing_type": [
                                "partial-payment"
                            ],
                            "current_balance": 100,
                            "external_account_number": "Ii3WNP93ePKV"
                        },
                        "messages": {
                            "external_id": [
                                "The external id has already been taken."
                            ]
                        }
                    },
                    {
                        "data": {
                            "balance": 100,
                            "metadata": {
                                "ut": "dolores",
                                "aut": "laboriosam",
                                "velit": "ut"
                            },
                            "external_id": "molestiae",
                            "billing_type": [
                                "partial-payment"
                            ],
                            "current_balance": 100,
                            "external_account_number": "kqipYsoS2hdN"
                        },
                        "messages": {
                            "external_id": [
                                "The external id has already been taken."
                            ]
                        }
                    }
                ]
            },
        }
    ]
}