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

# Create a customer

> Registers a customer under your tenant. `email` is required; `first_name`, `last_name`, `attributes` and a `cohort` holding `country_id`, `club_ids` and `metadata` are optional. Call it once per person, at signup or when importing an account you already hold. The response `data` carries the created customer, including its `id`, `username`, `status` and `onboarding_status`; keep the `id`, because every other customer route takes it. An email address already registered under the tenant returns 409. `X-Idempotency-Key` is required: a missing key returns 400 `IDEMPOTENCY_KEY_REQUIRED`, and a replay returns the stored response instead of creating a second record. Reusing a key with a different request returns 422 `IDEMPOTENCY_KEY_CONFLICT`, and replaying a key whose first request is still in flight returns 409 with the same code. A first request that never recorded a response keeps returning 409 until the key ages out, so send a fresh key rather than retrying that one.



## OpenAPI

````yaml /openapi/kintra-gateway.json post /gateway/customers
openapi: 3.0.0
info:
  description: >-
    Server-to-server API for the Kintra loyalty platform. Requests are
    authenticated with a tenant API key and a request signature; the tenant
    comes from the key.
  title: Kintra Gateway API
  version: 1.0.0
servers:
  - description: Production environment
    url: https://api.kintra.io/api/v1
security: []
paths:
  /gateway/customers:
    post:
      tags:
        - Customers
      summary: Create a customer
      description: >-
        Registers a customer under your tenant. `email` is required;
        `first_name`, `last_name`, `attributes` and a `cohort` holding
        `country_id`, `club_ids` and `metadata` are optional. Call it once per
        person, at signup or when importing an account you already hold. The
        response `data` carries the created customer, including its `id`,
        `username`, `status` and `onboarding_status`; keep the `id`, because
        every other customer route takes it. An email address already registered
        under the tenant returns 409. `X-Idempotency-Key` is required: a missing
        key returns 400 `IDEMPOTENCY_KEY_REQUIRED`, and a replay returns the
        stored response instead of creating a second record. Reusing a key with
        a different request returns 422 `IDEMPOTENCY_KEY_CONFLICT`, and
        replaying a key whose first request is still in flight returns 409 with
        the same code. A first request that never recorded a response keeps
        returning 409 until the key ages out, so send a fresh key rather than
        retrying that one.
      operationId: CreateCustomer
      parameters:
        - description: >-
            Hex HMAC-SHA256 of the timestamp, the uppercase method, the url as
            sent and the request body, keyed by the signing secret.
          in: header
          name: X-Tenant-Signature
          required: true
          schema:
            type: string
        - description: Unix seconds. Checked before the signature.
          in: header
          name: X-Tenant-Timestamp
          required: true
          schema:
            type: string
        - description: >-
            Unique key for this write. A replay returns the stored response; the
            same key with a different body conflicts.
          in: header
          name: X-Idempotency-Key
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ICustomerCreateDto'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_IUserProfileResponse_'
          description: Ok
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_IUserProfileResponse_'
          description: ''
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Unauthorized
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Tenant not found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Conflict
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_null_'
          description: Internal server error
      security:
        - tenant_api_key: []
      x-codeSamples:
        - label: cURL
          lang: bash
          source: >
            # Export KINTRA_API for your environment first; the base URL is on
            the introduction page.

            KEY="YOUR_TENANT_KEY_ID"

            SECRET="YOUR_SIGNING_SECRET"


            # The signature covers the path and query exactly as sent, so both
            are split

            # off the base URL and reused for the request line below.

            API_PATH="/${KINTRA_API#*://*/}"

            API_HOST="${KINTRA_API%"$API_PATH"}"

            METHOD="POST"

            PATH_AND_QUERY="$API_PATH/gateway/customers"


            # One compact line, signed and sent unchanged. The server signs a

            # re-serialization of the body it parsed, so reformatting this fails
            with a 401.

            BODY='{"email":"YOUR_EMAIL"}'


            TIMESTAMP="$(date +%s)"

            SIGNATURE="$(printf '%s' "$TIMESTAMP$METHOD$PATH_AND_QUERY$BODY" \
              | openssl dgst -sha256 -hmac "$SECRET" | awk '{print $NF}')"

            curl -sS -w '\n%{http_code}' -X "$METHOD" "$API_HOST$PATH_AND_QUERY"
            \
              -H "X-Tenant-Key: $KEY" \
              -H "X-Tenant-Timestamp: $TIMESTAMP" \
              -H "X-Tenant-Signature: $SIGNATURE" \
              -H "Content-Type: application/json" \
              -H "X-Idempotency-Key: YOUR_IDEMPOTENCY_KEY" \
              --data-binary "$BODY"
        - label: TypeScript
          lang: typescript
          source: >
            import { createHmac } from 'node:crypto'


            // Export KINTRA_API for your environment first; the base URL is on
            the introduction page.

            const { origin, pathname } = new URL(process.env.KINTRA_API ?? '')

            const key = 'YOUR_TENANT_KEY_ID'

            const secret = 'YOUR_SIGNING_SECRET'


            const method = 'POST'

            // The signature covers the path and query as sent, starting at the
            API prefix.

            const pathAndQuery = `${pathname}/gateway/customers`


            // Serialized once and used twice. The server signs a
            re-serialization of the

            // body it parsed, so the bytes signed and the bytes sent have to be
            identical.

            const body = JSON.stringify({
              "email": "YOUR_EMAIL"
            })


            const timestamp = Math.floor(Date.now() / 1000).toString()

            const signature = createHmac('sha256',
            secret).update(`${timestamp}${method}${pathAndQuery}${body}`).digest('hex')


            const response = await fetch(`${origin}${pathAndQuery}`, {
              method,
              headers: {
                'X-Tenant-Key': key,
                'X-Tenant-Timestamp': timestamp,
                'X-Tenant-Signature': signature,
                'Content-Type': 'application/json',
                'X-Idempotency-Key': 'YOUR_IDEMPOTENCY_KEY'
              },
              body
            })


            console.log(response.status, await response.json())
components:
  schemas:
    ICustomerCreateDto:
      additionalProperties: false
      properties:
        attributes:
          $ref: >-
            #/components/schemas/Record_string.string-or-number-or-string-Array-or-null_
          description: >-
            Optional initial attribute values, keyed by definition id. Mirrors
            the PUT attributes body.
        cohort:
          $ref: '#/components/schemas/ICohortUpsertPayloadDto'
        email:
          type: string
        first_name:
          description: Optional human first name. Captured on the tenant Add User form.
          type: string
        last_name:
          description: Optional human last name. Captured on the tenant Add User form.
          type: string
      required:
        - email
      type: object
    ApiResponse_IUserProfileResponse_:
      additionalProperties: false
      properties:
        data:
          $ref: '#/components/schemas/IUserProfileResponse'
        errors:
          items:
            properties:
              message:
                type: string
              path:
                type: string
            required:
              - path
              - message
            type: object
          type: array
        message:
          type: string
        success:
          type: boolean
      required:
        - success
      type: object
    ApiResponse_null_:
      additionalProperties: false
      properties:
        data:
          enum:
            - null
          nullable: true
          type: number
        errors:
          items:
            properties:
              message:
                type: string
              path:
                type: string
            required:
              - path
              - message
            type: object
          type: array
        message:
          type: string
        success:
          type: boolean
      required:
        - success
      type: object
    Record_string.string-or-number-or-string-Array-or-null_:
      additionalProperties:
        anyOf:
          - type: string
          - format: double
            type: number
          - items:
              type: string
            type: array
      description: Construct a type with a set of properties K of type T
      properties: {}
      type: object
    ICohortUpsertPayloadDto:
      additionalProperties: false
      properties:
        club_ids:
          items:
            type: string
          type: array
        country_id:
          type: string
        metadata:
          $ref: '#/components/schemas/Record_string.unknown_'
      type: object
    IUserProfileResponse:
      additionalProperties: false
      properties:
        auth_provider:
          type: string
        auth_provider_id:
          type: string
        created_at:
          format: date-time
          nullable: true
          type: string
        email:
          type: string
        first_name:
          nullable: true
          type: string
        id:
          type: string
        internal_wallets:
          items:
            $ref: '#/components/schemas/IInternalWalletResponse'
          type: array
        last_name:
          nullable: true
          type: string
        onboarding_status:
          anyOf:
            - $ref: '#/components/schemas/UserOnboardingStatus'
            - type: string
        onboarding_type:
          anyOf:
            - $ref: '#/components/schemas/UserOnboardingType'
            - type: string
          nullable: true
        status:
          type: string
        updated_at:
          format: date-time
          nullable: true
          type: string
        username:
          type: string
      required:
        - id
        - username
        - email
        - auth_provider
        - auth_provider_id
        - status
        - onboarding_status
      type: object
    Record_string.unknown_:
      additionalProperties: {}
      description: Construct a type with a set of properties K of type T
      properties: {}
      type: object
    IInternalWalletResponse:
      additionalProperties: false
      properties:
        address:
          type: string
        created_at:
          format: date-time
          type: string
        deleted_at:
          format: date-time
          nullable: true
          type: string
        id:
          type: string
        label:
          nullable: true
          type: string
        updated_at:
          format: date-time
          type: string
        user_id:
          type: string
        wallet_kind:
          type: string
      required:
        - id
        - address
        - wallet_kind
        - user_id
      type: object
    UserOnboardingStatus:
      enum:
        - initial
        - registered
        - active
      type: string
    UserOnboardingType:
      enum:
        - admin
        - tenant
        - user
      type: string
  securitySchemes:
    tenant_api_key:
      description: Tenant API key
      in: header
      name: x-tenant-key
      type: apiKey

````