# Create a customer (/docs/api/customers/create-customer)

Registers a person or business you act for, under your own external_id. The same external_id sent again with the same identity (type, country, display_name, profile) returns the existing customer (200); with a different identity it is a 409 conflict. metadata is yours and is not compared.

The operation, from the OpenAPI contract (https://docs.caibopay.app/openapi.json):

```json

{
  "method": "POST",
  "path": "/v1/customers",
  "description": "Registers a person or business you act for, under your own external_id. The same external_id sent again with the same identity (type, country, display_name, profile) returns the existing customer (200); with a different identity it is a 409 conflict. metadata is yours and is not compared.",
  "operationId": "createCustomer",
  "parameters": [
    {
      "$ref": "#/components/parameters/IdempotencyKey"
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/CustomerCreate"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Customer"
          }
        }
      },
      "description": "The request was already made: the existing resource is returned.",
      "headers": {
        "Idempotent-Replayed": {
          "schema": {
            "enum": [
              "true"
            ],
            "type": "string"
          }
        }
      }
    },
    "201": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Customer"
          }
        }
      },
      "description": "Created"
    },
    "400": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The request is not valid."
    },
    "401": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The API key is missing or not valid."
    },
    "403": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The API key lacks the required scope."
    },
    "409": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The Idempotency-Key was used with a different request, or the resource is in conflict."
    },
    "422": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "The request is well formed but cannot be carried out."
    },
    "429": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "Too many requests."
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "An error on our side. Safe to retry with the same Idempotency-Key."
    },
    "503": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "Temporarily unavailable or suspended. Safe to retry with the same Idempotency-Key."
    }
  },
  "summary": "Create a customer",
  "tags": [
    "Customers"
  ],
  "x-required-scope": "write",
  "x-codeSamples": [
    {
      "lang": "js",
      "label": "Node.js",
      "source": "import { Caibo } from \"caibopay\";\n\nconst caibo = new Caibo(process.env.CAIBO_API_KEY);\n\nconst result = await caibo.customers.create({\n  country: \"...\",\n  display_name: \"...\",\n  external_id: \"id_...\",\n  type: \"individual\",\n}, { idempotencyKey: \"your-operation-id\" });"
    },
    {
      "lang": "python",
      "label": "Python",
      "source": "import os\n\nimport caibopay\n\nclient = caibopay.Client(os.environ[\"CAIBO_API_KEY\"])\n\nresult = client.customers.create(country=\"...\", display_name=\"...\", external_id=\"id_...\", type=\"individual\", idempotency_key=\"your-operation-id\")"
    },
    {
      "lang": "go",
      "label": "Go",
      "source": "client, err := caibopay.NewClient(os.Getenv(\"CAIBO_API_KEY\"))\nif err != nil {\n\treturn err\n}\nctx := context.Background()\n\nresult, err := client.Customers.Create(ctx, &caibopay.CustomerCreate{\n\tCountry: \"...\",\n\tDisplayName: \"...\",\n\tExternalID: \"id_...\",\n\tType: \"individual\",\n}, caibopay.WithIdempotencyKey(\"your-operation-id\"))\nif err != nil {\n\treturn err\n}\nfmt.Println(result)"
    }
  ]
}

```