---
title: Create many customers
slug: amberflo-api/create-many-customers
createdAt: 2024-11-07T15:10:16.978Z
---

{
  "id": "ud0J7rxwXXYw4lJhGcFHl",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/customers/batch",
    "servers": [
      {
        "url": "https://app.amberflo.io/customers/batch"
      }
    ],
    "name": "Create many customers",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [
        {
          "kind": "optional",
          "name": "autoCreateCustomerInStripe",
          "type": "string",
          "description": "<p>Indicates whether to create the customer in your Stripe account or not.</p>\n<p>Its Stripe id is saved as the <code>stripeId</code> trait after it is created there.</p>\n<p>When set to <code>if_payment_provider</code>, then it will only be created in Stripe if the <code>paymentProviderName</code> trait is set to <code>STRIPE</code></p>"
        }
      ],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "array",
          "description": "",
          "customType": "metadata.customer.CustomerDetails.in[]",
          "schema": [
            {
              "name": "customerId",
              "kind": "required",
              "type": "string",
              "description": "Id of the customer, as it exists in your system.",
              "example": ""
            },
            {
              "name": "customerName",
              "kind": "required",
              "type": "string",
              "description": "Name of the customer, as it exists in your system.",
              "example": ""
            },
            {
              "name": "customerEmail",
              "kind": "optional",
              "type": "string",
              "description": "Email of the customer, as it exists in your system.",
              "example": ""
            },
            {
              "name": "description",
              "kind": "optional",
              "type": "string",
              "description": "Description of the customer.",
              "example": ""
            },
            {
              "name": "enabled",
              "kind": "optional",
              "type": "boolean",
              "deprecated": true,
              "description": "Determines whether the customer is active or not. Setting it to false deactivates the customer. Only relevant when updating a customer.\n\nNote that this field is superseded by the `lifecycleStage` one, which allows finer grained control. When `enabled = false` means `lifecycleStage = OFFBOARDED`, other lifecycle stages mean `enabled = true` and vice-versa.",
              "example": ""
            },
            {
              "name": "test",
              "kind": "optional",
              "type": "boolean",
              "description": "Determines whether the customer is a test customer. Can only be set once during creation. Test customers can be excluded from certain operations.\n\nDefaults to `false`.",
              "example": ""
            },
            {
              "name": "lifecycleStage",
              "kind": "optional",
              "type": "string",
              "description": "The lifecycle stage of a customer. The lifecycle stage of a customer determines which features of the system are enabled for it.\n\nValid lifecycle stages are:\n- `ONBOARDING` - Only usage is tracked.\n- `TRAIL` - Both usage and billing data are tracked but customer will not be charged.\n- `ACTIVE` - Both usage and billing data are tracked and customer will be charged.\n- `OFFBOARDED` - Only usage is tracked.\n\nDefault: `ACTIVE`",
              "modelRef": "#/components/schemas/metadata.customer.CustomerLifecycleStage.in",
              "customType": "metadata.customer.CustomerLifecycleStage.in",
              "schema": []
            },
            {
              "name": "traits",
              "kind": "optional",
              "type": "map",
              "description": "Reference metadata to integrate with external systems like billing.\n\nThe following traits are used by Amberflo:\n- `stripeId` for [integrating with Stripe](doc:stripe);\n- `awsm.customerIdentifier` for [integrating with AWS Marketplace](doc:associating-customers-with-aws-marketplace);\n- `currency` for the customer's currency, following the ISO standard.\n",
              "example": "",
              "customType": "map<string, string>",
              "schema": []
            },
            {
              "name": "address",
              "kind": "optional",
              "type": "object",
              "description": "Tax address of the customer.",
              "modelRef": "#/components/schemas/metadata.customer.CustomerAddress.in",
              "customType": "metadata.customer.CustomerAddress.in",
              "schema": [
                {
                  "name": "line1",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "state",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "city",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "postalCode",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "country",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                }
              ]
            }
          ],
          "modelRef": "#/components/schemas/metadata.customer.CustomerDetails.in",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "array",
            "description": "",
            "customType": "metadata.customer.result.CustomerResult.out[]",
            "schema": [
              {
                "name": "customer",
                "kind": "optional",
                "type": "object",
                "description": "Customer details. Only valid `error` is not set.",
                "modelRef": "#/components/schemas/metadata.customer.CustomerDetails.out",
                "customType": "metadata.customer.CustomerDetails.out",
                "schema": [
                  {
                    "name": "createTime",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "description": "Creation time in [Unix time](https://en.wikipedia.org/wiki/Unix_time) (milliseconds)",
                    "example": 0
                  },
                  {
                    "name": "updateTime",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "description": "Update time in [Unix time](https://en.wikipedia.org/wiki/Unix_time) (milliseconds)",
                    "example": 0
                  },
                  {
                    "name": "deleteTime",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "example": 0
                  },
                  {
                    "name": "customerId",
                    "kind": "required",
                    "type": "string",
                    "description": "Id of the customer, as it exists in your system.",
                    "example": ""
                  },
                  {
                    "name": "customerName",
                    "kind": "required",
                    "type": "string",
                    "description": "Name of the customer, as it exists in your system.",
                    "example": ""
                  },
                  {
                    "name": "customerEmail",
                    "kind": "optional",
                    "type": "string",
                    "description": "Email of the customer, as it exists in your system.",
                    "example": ""
                  },
                  {
                    "name": "description",
                    "kind": "optional",
                    "type": "string",
                    "description": "Description of the customer.",
                    "example": ""
                  },
                  {
                    "name": "enabled",
                    "kind": "optional",
                    "type": "boolean",
                    "deprecated": true,
                    "description": "Determines whether the customer is active or not. Setting it to false deactivates the customer. Only relevant when updating a customer.\n\nNote that this field is superseded by the `lifecycleStage` one, which allows finer grained control. When `enabled = false` means `lifecycleStage = OFFBOARDED`, other lifecycle stages mean `enabled = true` and vice-versa.",
                    "example": ""
                  },
                  {
                    "name": "test",
                    "kind": "optional",
                    "type": "boolean",
                    "description": "Determines whether the customer is a test customer. Can only be set once during creation. Test customers can be excluded from certain operations.\n\nDefaults to `false`.",
                    "example": ""
                  },
                  {
                    "name": "lifecycleStage",
                    "kind": "optional",
                    "type": "string",
                    "description": "The lifecycle stage of a customer. The lifecycle stage of a customer determines which features of the system are enabled for it.\n\nValid lifecycle stages are:\n- `ONBOARDING` - Only usage is tracked.\n- `TRAIL` - Both usage and billing data are tracked but customer will not be charged.\n- `ACTIVE` - Both usage and billing data are tracked and customer will be charged.\n- `OFFBOARDED` - Only usage is tracked.\n\nDefault: `ACTIVE`",
                    "modelRef": "#/components/schemas/metadata.customer.CustomerLifecycleStage.out",
                    "customType": "metadata.customer.CustomerLifecycleStage.out",
                    "schema": []
                  },
                  {
                    "name": "deactivateTimeStamp",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "example": 0
                  },
                  {
                    "name": "traits",
                    "kind": "optional",
                    "type": "map",
                    "description": "Reference metadata to integrate with external systems like billing.\n\nThe following traits are used by Amberflo:\n- `stripeId` for [integrating with Stripe](doc:stripe);\n- `awsm.customerIdentifier` for [integrating with AWS Marketplace](doc:associating-customers-with-aws-marketplace);\n- `currency` for the customer's currency, following the ISO standard.\n",
                    "example": "",
                    "customType": "map<string, string>",
                    "schema": []
                  },
                  {
                    "name": "address",
                    "kind": "optional",
                    "type": "object",
                    "description": "Tax address of the customer.",
                    "modelRef": "#/components/schemas/metadata.customer.CustomerAddress.out",
                    "customType": "metadata.customer.CustomerAddress.out",
                    "schema": [
                      {
                        "name": "verified",
                        "kind": "optional",
                        "type": "boolean",
                        "example": ""
                      },
                      {
                        "name": "line1",
                        "kind": "required",
                        "type": "string",
                        "example": ""
                      },
                      {
                        "name": "state",
                        "kind": "optional",
                        "type": "string",
                        "example": ""
                      },
                      {
                        "name": "city",
                        "kind": "required",
                        "type": "string",
                        "example": ""
                      },
                      {
                        "name": "postalCode",
                        "kind": "optional",
                        "type": "string",
                        "example": ""
                      },
                      {
                        "name": "country",
                        "kind": "required",
                        "type": "string",
                        "example": ""
                      }
                    ]
                  }
                ]
              },
              {
                "name": "error",
                "kind": "optional",
                "type": "object",
                "description": "If set, indicates there was some error handling this customer, and contains the details of the error.",
                "modelRef": "#/components/schemas/com.amberflo.service.common.rest_api.models.ErrorDetails.out",
                "customType": "com.amberflo.service.common.rest_api.models.ErrorDetails.out",
                "schema": [
                  {
                    "name": "errorMessage",
                    "kind": "optional",
                    "type": "string",
                    "description": "Error message.",
                    "example": ""
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/metadata.customer.result.CustomerResult.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/customers/batch \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '[\n     {\n     \"customerId\": \"\",\n     \"customerName\": \"\",\n     \"address\": {\n     \"line1\": \"\",\n     \"city\": \"\",\n     \"country\": \"\"\n     }\n     }\n     ]'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify([\n   {\n      \"customerId\": \"\",\n      \"customerName\": \"\",\n      \"address\": {\n         \"line1\": \"\",\n         \"city\": \"\",\n         \"country\": \"\"\n      }\n   }\n]);\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/customers/batch\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/customers/batch\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump([\n   {\n      \"customerId\": \"\",\n      \"customerName\": \"\",\n      \"address\": {\n         \"line1\": \"\",\n         \"city\": \"\",\n         \"country\": \"\"\n      }\n   }\n])\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/customers/batch\"\n\npayload = json.dumps([\n   {\n      \"customerId\": \"\",\n      \"customerName\": \"\",\n      \"address\": {\n         \"line1\": \"\",\n         \"city\": \"\",\n         \"country\": \"\"\n      }\n   }\n])\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful request\n[\n  {\n    \"customer\": {\n      \"createTime\": \"\",\n      \"updateTime\": \"\",\n      \"deleteTime\": \"\",\n      \"customerId\": \"\",\n      \"customerName\": \"\",\n      \"customerEmail\": \"\",\n      \"description\": \"\",\n      \"enabled\": false,\n      \"test\": false,\n      \"lifecycleStage\": \"\",\n      \"deactivateTimeStamp\": \"\",\n      \"traits\": \"\",\n      \"address\": {\n        \"verified\": false,\n        \"line1\": \"\",\n        \"state\": \"\",\n        \"city\": \"\",\n        \"postalCode\": \"\",\n        \"country\": \"\"\n      }\n    },\n    \"error\": {\n      \"errorMessage\": \"\"\n    }\n  }\n]"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}