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

# Create Customer

> Creates a customer object.



<Note>

<Badge color="blue">Upsert Mode</Badge>

If you pass an `id` or a `source_id` that already exists in the customer database, Voucherify will return a related customer object with updated fields.

</Note>



## OpenAPI

````yaml /openapi/customers.json post /v1/customers
openapi: 3.1.0
info:
  title: Voucherify API - Customers
  version: v2018-08-01
  description: >-
    Voucherify promotion engine REST API. Please see
    https://docs.voucherify.io/docs for more details.
  contact:
    name: Voucherify Team
    url: https://www.voucherify.io/contact-support
    email: support@voucherify.io
  termsOfService: https://www.voucherify.io/legal/subscription-agreement
  license:
    name: MIT
    url: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/LICENSE
servers:
  - url: https://{cluster}.voucherify.io
    description: Base URL
    variables:
      cluster:
        default: api
        enum:
          - api
          - us1.api
          - as1.api
          - download
          - us1.download
          - as1.download
security: []
paths:
  /v1/customers:
    post:
      tags:
        - Customers
      summary: Create Customer
      description: >-
        Creates a customer object.




        <Note>


        <Badge color="blue">Upsert Mode</Badge>


        If you pass an `id` or a `source_id` that already exists in the customer
        database, Voucherify will return a related customer object with updated
        fields.


        </Note>
      operationId: create-customer
      parameters: []
      requestBody:
        description: Create a customer with specified parameters.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomersCreateRequestBody'
            examples:
              Example:
                value:
                  source_id: source_123
                  name: Bob Smith
                  description: A frequent customer
                  email: bob.smith@email.com
                  phone: +1 933 222 3333
                  address:
                    city: New York
                    country: United States
                    line_1: 123 Main St.
                    line_2: APT 3 BLG 4
                    postal_code: '10001'
                    state: NY
                  metadata:
                    lang: en
                    test: true
                  birthdate: '2022-01-01'
        required: true
      responses:
        '200':
          description: Returns a customer object.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomersCreateResponseBody'
              examples:
                Example:
                  value:
                    id: cust_CSnYd37MXmrbS19XCrghjBsv
                    source_id: source_123
                    name: Bob Smith
                    description: A frequent customer
                    email: bob.smith@email.com
                    phone: +1 933 222 3333
                    birthdate: '2022-01-01'
                    address:
                      city: New York
                      state: NY
                      line_1: 123 Main St.
                      line_2: APT 3 BLG 4
                      country: United States
                      postal_code: '10001'
                    summary:
                      redemptions:
                        total_redeemed: 0
                        total_failed: 0
                        total_succeeded: 0
                        total_rolled_back: 0
                        total_rollback_failed: 0
                        total_rollback_succeeded: 0
                        gift:
                          redeemed_amount: 0
                          amount_to_go: 0
                        loyalty_card:
                          redeemed_points: 0
                          points_to_go: 0
                      orders:
                        total_amount: 0
                        total_count: 0
                        average_amount: 0
                        last_order_amount: 0
                    loyalty:
                      points: 0
                      referred_customers: 0
                      campaigns: {}
                    referrals:
                      total: 0
                      campaigns: []
                    metadata:
                      lang: en
                      test: true
                    system_metadata: {}
                    created_at: '2022-08-30T06:32:07.380Z'
                    object: customer
      security:
        - X-App-Id: []
          X-App-Token: []
        - X-Voucherify-OAuth:
            - api
            - customers
components:
  schemas:
    CustomersCreateRequestBody:
      title: Customers Create Request Body
      description: Request body schema for **POST** `v1/customers`.
      allOf:
        - $ref: '#/components/schemas/Customer'
    CustomersCreateResponseBody:
      description: Response body for **POST** `v1/customers`.
      title: Customers Create Response Body
      allOf:
        - $ref: '#/components/schemas/CustomerWithSummaryLoyaltyReferrals'
    Customer:
      title: Customer
      allOf:
        - type: object
          title: Customer Id And Source Id
          properties:
            id:
              type: string
              description: The ID of an existing customer.
            source_id:
              type: string
              description: >-
                A unique identifier of the customer who validates a voucher. It
                can be a customer ID or email from a CRM system, database, or a
                third-party service. If you also pass a customer ID (unique ID
                assigned by Voucherify), the source ID will be ignored.
        - $ref: '#/components/schemas/CustomerBase'
    CustomerWithSummaryLoyaltyReferrals:
      title: Customer With Summary Loyalty Referrals
      allOf:
        - type: object
          title: Customer Response Data
          properties:
            id:
              type: string
              description: >-
                The ID of an existing customer that will be linked to redemption
                in this request.
            source_id:
              type: string
              description: >-
                A unique identifier of the customer who validates a voucher. It
                can be a customer ID or email from a CRM system, database, or a
                third-party service. If you also pass a customer ID (unique ID
                assigned by Voucherify), the source ID will be ignored.
            summary:
              anyOf:
                - $ref: '#/components/schemas/CustomerSummary'
                - type: 'null'
            loyalty:
              anyOf:
                - $ref: '#/components/schemas/CustomerLoyalty'
                - type: 'null'
            loyalty_memberships:
              description: >-
                List of Loyalty v2 program memberships for the customer. Lists
                only existing `ACTIVE` memberships. `null` when no memberships
                are stored. Absent or `null` for `v1/orders` and
                `v1/publications` endpoints and events.
              anyOf:
                - type: array
                  items:
                    $ref: '#/components/schemas/CustomerLoyaltyMembership'
                - type: 'null'
            referrals:
              anyOf:
                - $ref: '#/components/schemas/CustomerReferrals'
                - type: 'null'
            system_metadata:
              type: object
              description: Object used to store system metadata information.
            created_at:
              type: string
              description: >-
                Timestamp representing the date and time when the customer was
                created. The value is shown in the ISO 8601 format.
              example: '2022-08-30T06:32:07.380Z'
              format: date-time
            updated_at:
              type: string
              description: >-
                Timestamp representing the date and time when the customer was
                updated. The value is shown in the ISO 8601 format.
              example: '2022-08-31T06:32:07.380Z'
              format: date-time
            assets:
              type: object
              description: >-
                Contains information about the customer's cockpit.


                ⚠️ Warning: Customer cockpits were removed. The customer cockpit
                URLs redirect to customer preference center.
              properties:
                cockpit_url:
                  type: string
                  description: >-
                    URL address to customer preference center. Previously, a
                    customer's cockpit URL address.
                cockpit_preference_center_url:
                  type: string
                  description: URL address to customer preference center.
            object:
              type: string
              description: The type of the object represented by JSON.
              default: customer
              enum:
                - customer
          required:
            - summary
            - loyalty
            - loyalty_memberships
            - referrals
            - object
        - $ref: '#/components/schemas/CustomerBase'
    CustomerBase:
      title: Customer Base
      type: object
      properties:
        name:
          type: string
          description: Customer's first and last name.
        description:
          type: string
          description: An arbitrary string that you can attach to a customer object.
        email:
          type: string
          description: Customer's email address.
        phone:
          type: string
          description: >-
            Customer's phone number. This parameter is mandatory when you try to
            send out codes to customers via an SMS channel.
        birthday:
          type: string
          description: '`Deprecated`. ~~Customer''s birthdate; format YYYY-MM-DD~~.'
          format: date
        birthdate:
          type: string
          description: Customer's birthdate; format YYYY-MM-DD.
          format: date
        address:
          type:
            - object
            - 'null'
          description: Customer's address.
          properties:
            city:
              type: string
              description: City
            state:
              type: string
              description: State
            line_1:
              type: string
              description: First line of address.
            line_2:
              type: string
              description: Second line of address.
            country:
              type: string
              description: Country.
            postal_code:
              type: string
              description: Postal code.
        metadata:
          type: object
          description: >-
            A set of custom key/value pairs that you can attach to a customer.
            The metadata object stores all custom attributes assigned to the
            customer. It can be useful for storing additional information about
            the customer in a structured format. This metadata can be used for
            validating whether the customer qualifies for a discount or it can
            be used in building customer segments.
    CustomerSummary:
      title: Customer Summary
      type: object
      properties:
        redemptions:
          $ref: '#/components/schemas/CustomerSummaryRedemptions'
        orders:
          $ref: '#/components/schemas/CustomerSummaryOrders'
      required:
        - redemptions
        - orders
    CustomerLoyalty:
      title: Customer Loyalty
      type: object
      properties:
        points:
          type: integer
          description: >-
            Customer's loyalty points minus expired points for all loyalty cards
            (**legacy loyalty**) which the customer has.
        referred_customers:
          type: integer
          description: Total number of customers referred by the customer.
        campaigns:
          type: object
          description: >-
            Contains **legacy loyalty** and referral campaigns with details
            about point balances and how many customers were referred by the
            customer.
          additionalProperties:
            type: object
            description: >-
              Contains details about the point balances left on loyalty cards
              (**legacy loyalty**) and the number of referred customers in each
              campaign.
            properties:
              points:
                type: integer
                description: Remaining point balance in campaign.
              loyalty_tier:
                type: string
                example: ltr_UJ5Q54Q0OvEhua87Qfv2Ki5x
                description: >-
                  Customer's loyalty tier within the **legacy loyalty**
                  campaign.
              referred_customers:
                type: integer
                description: Number of customers referred by the customer in campaign.
      required:
        - points
        - referred_customers
        - campaigns
      description: >-
        Summary of the customer's **legacy loyalty** activity: points on loyalty
        cards and referred customers. Loyalty hub memberships are listed
        separately under `loyalty_memberships` on the customer object.
    CustomerLoyaltyMembership:
      title: Customer Loyalty Membership
      type: object
      description: Loyalty v2 program membership stored on the customer.
      properties:
        program_id:
          type: string
          pattern: ^lprg_[a-f0-9]+$
          description: Identifies the Loyalty v2 program.
        member:
          description: Program member. `null` when the membership has no member record.
          anyOf:
            - $ref: '#/components/schemas/CustomerLoyaltyMembershipMember'
            - type: 'null'
        cards:
          type: array
          description: List of loyalty cards in this program.
          items:
            $ref: '#/components/schemas/CustomerLoyaltyMembershipCard'
        tiers:
          type: array
          description: List of tiers held in this program.
          items:
            $ref: '#/components/schemas/CustomerLoyaltyMembershipTier'
      required:
        - program_id
        - member
        - cards
        - tiers
    CustomerReferrals:
      title: Customer Referrals
      type: object
      description: >-
        Summary of customer's referrals, in this case, the customer being the
        referee, i.e. information about the source of referrals and number of
        times the customer was referred by other customers.
      properties:
        total:
          type: integer
          description: >-
            Total number of times this customer received a referral, i.e. was
            referred by another customer.
        campaigns:
          type: array
          description: >-
            Contains an array of campaigns that served as the source of a
            referral for the customer.
          items:
            title: Customer Referrals Campaigns Item
            type: object
            description: Contains information about the source of the referral.
            properties:
              campaign_id:
                type: string
                description: Unique campaign ID, assigned by Voucherify.
                example: camp_rRsfatlwN7unSeUIJDCYedal
              referrer_id:
                type: string
                example: cust_sehkNIi8Uq2qQuRqSr7xn4Zi
                description: >-
                  Unique referrer ID, assigned by Voucherify. This is the
                  customer ID of a customer that is referring this customer.
              related_object_id:
                type: string
                description: Related object id
                example: r_0b9d4cc4aa164dd073
              related_object_type:
                type: string
                description: Related object type, i.e. `redemption`.
              date:
                type: string
                format: date-time
                example: '2022-08-30T10:19:39.196Z'
                description: >-
                  Timestamp representing the date and time when the customer was
                  referred in ISO 8601 format.
            required:
              - campaign_id
              - referrer_id
              - related_object_id
              - related_object_type
              - date
      required:
        - total
        - campaigns
    CustomerSummaryRedemptions:
      title: Customer Summary Redemptions
      type: object
      properties:
        total_redeemed:
          type: integer
          description: Total number of redemptions made by the customer.
        total_failed:
          type: integer
          description: Total number of redemptions that failed.
        total_succeeded:
          type: integer
          description: Total number of redemptions that succeeded.
        total_rolled_back:
          type: integer
          description: Total number of redemptions that were rolled back for the customer.
        total_rollback_failed:
          type: integer
          description: Total number of redemption rollbacks that failed.
        total_rollback_succeeded:
          type: integer
          description: Total number of redemption rollbacks that succeeded.
        gift:
          type: object
          description: Summary of gift card credits.
          required:
            - redeemed_amount
            - amount_to_go
          properties:
            redeemed_amount:
              type: integer
              description: >-
                Total amount of gift card credits redeemed by customer. The
                value is multiplied by 100 to represent 2 decimal places. For
                example `10000 cents` for `$100.00`.
              default: 0
            amount_to_go:
              type: integer
              description: >-
                Remaining gift card balance across all gift cards. The value is
                multiplied by 100 to represent 2 decimal places. For example
                `10000 cents` for `$100.00`.
              default: 0
        loyalty_card:
          type: object
          description: Summary of loyalty points (**legacy loyalty**).
          required:
            - redeemed_points
            - points_to_go
          properties:
            redeemed_points:
              type: integer
              description: Total number of loyalty points redeemed by the customer.
            points_to_go:
              type: integer
              description: >-
                Sum of remaining available point balance across all loyalty
                cards.
      required:
        - total_redeemed
        - total_failed
        - total_succeeded
        - total_rolled_back
        - total_rollback_failed
        - total_rollback_succeeded
        - gift
        - loyalty_card
    CustomerSummaryOrders:
      title: Customer Summary Orders
      description: >-
        Lists details about orders related to the customer. Lists only data for
        orders with the `PAID` or `FULFILLED` status. Data from orders with a
        `CREATED` or `CANCELED` status are not included. The data is updated
        also when an order changes status.
      type: object
      properties:
        total_amount:
          type: integer
          description: >-
            The total amount spent by the customer. The value is multiplied by
            100 to represent 2 decimal places. For example `10000 cents` for
            `$100.00`.
        total_count:
          type: integer
          description: Total number of orders made by the customer.
        average_amount:
          type: integer
          description: >-
            Average amount spent on orders. `total_amount` &divide;
            `total_count`. The value is multiplied by 100 to represent 2 decimal
            places. For example `10000 cents` for `$100.00`.
        last_order_amount:
          type: integer
          description: >-
            Amount spent on last order. The value is multiplied by 100 to
            represent 2 decimal places. For example `10000 cents` for `$100.00`.
        last_order_date:
          type: string
          format: date-time
          example: '2022-08-30T11:51:08.029Z'
          description: >-
            Timestamp representing the date and time of the customer's last
            order in ISO 8601 format.
      required:
        - total_amount
        - total_count
        - average_amount
        - last_order_amount
    CustomerLoyaltyMembershipMember:
      title: Customer Loyalty Membership Member
      type: object
      description: Loyalty v2 member recorded on the customer membership.
      properties:
        id:
          type: string
          pattern: ^lmbr_[a-f0-9]+$
          description: Identifies the Loyalty v2 program member.
        status:
          type: string
          enum:
            - ACTIVE
          description: Member status. The value is `ACTIVE`.
        created_at:
          type: string
          format: date-time
          description: >-
            Timestamp representing when the member was created. The value is
            shown in the ISO 8601 format.
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Timestamp representing when the member was updated. The value is
            shown in the ISO 8601 format. `null` when not set.
      required:
        - id
        - status
        - created_at
        - updated_at
    CustomerLoyaltyMembershipCard:
      title: Customer Loyalty Membership Card
      type: object
      description: Loyalty card balance recorded on the customer membership.
      properties:
        card_definition_id:
          type: string
          pattern: ^lcdef_[a-f0-9]+$
          description: Identifies the card definition.
        card_id:
          type: string
          pattern: ^lcrd_[a-f0-9]+$
          description: Identifies the loyalty card.
        points:
          type: number
          description: Points balance on the card.
        pending_points:
          type: number
          description: Pending points on the card.
        next_activation_at:
          type:
            - string
            - 'null'
          format: date
          description: >-
            Date when the next points become active, in `YYYY-MM-DD` format.
            `null` when no activation is scheduled.
        next_expiration_at:
          type:
            - string
            - 'null'
          format: date
          description: >-
            Date when the next points expire, in `YYYY-MM-DD` format. `null`
            when no expiration is scheduled.
      required:
        - card_definition_id
        - card_id
        - points
        - pending_points
        - next_activation_at
        - next_expiration_at
    CustomerLoyaltyMembershipTier:
      title: Customer Loyalty Membership Tier
      type: object
      description: Tier recorded on the customer membership.
      properties:
        tier_id:
          type: string
          pattern: ^lt_[a-f0-9]+$
          description: Identifies the tier.
        tier_structure_id:
          type: string
          pattern: ^lts_[a-f0-9]+$
          description: Identifies the tier structure.
        card_id:
          type: string
          pattern: ^lcrd_[a-f0-9]+$
          description: Identifies the loyalty card that holds this tier.
        card_definition_id:
          type: string
          pattern: ^lcdef_[a-f0-9]+$
          description: Identifies the card definition for this tier.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Timestamp representing when the tier expires. The value is shown in
            the ISO 8601 format. `null` when the tier does not expire.
      required:
        - tier_id
        - tier_structure_id
        - card_id
        - card_definition_id
        - expires_at
  securitySchemes:
    X-App-Id:
      type: apiKey
      name: X-App-Id
      in: header
    X-App-Token:
      type: apiKey
      name: X-App-Token
      in: header
    X-Voucherify-OAuth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://api.voucherify.io/v1/oauth/token
          scopes:
            api: Gives access to whole server-side API.
            vouchers: >-
              Gives access to all endpoints and methods starting with
              `v1/vouchers`.
            client_api: Gives access to whole client-side API.
            client_vouchers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/vouchers`.
            promotions: >-
              Gives access to all endpoints and methods starting with
              `/v1/promotions`.
            client_promotions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/promotions`
            campaigns: >-
              Gives access to all endpoints and methods starting with
              `v1/campaigns`.
            client_publish: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/publish`.
            exports: >-
              Gives access to all endpoints and methods starting with
              `/v1/exports`.
            publications: >-
              Gives access to all endpoints and methods starting with
              `/v1/publications`.
            client_validate: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validate`.
            validations: >-
              Gives access to all endpoints and methods starting with
              `/v1/validations`.
            client_validations: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validations`.
            qualifications: >-
              Gives access to all endpoints and methods starting with
              `/v1/qualifications`.
            client_qualifications: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/qualifications`.
            client_redeem: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redeem
            redemptions: >-
              Gives access to all endpoints and methods starting with
              `/v1/redemptions`.
            client_redemptions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redemptions`
            customers: >-
              Gives access to all endpoints and methods starting with
              `/v1/customers`.
            client_customers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/customers`.
            orders: >-
              Gives access to all endpoints and methods starting with
              `/v1/orders`.
            products: >-
              Gives access to all endpoints and methods starting with
              `/v1/products`.
            skus: >-
              Gives access to all endpoints and methods starting with
              `/v1/SKUs`.
            validation-rules: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules`.
            validation-rules-assignments: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules-assignments
            segments: >-
              Gives access to all endpoints and methods starting with
              `/v1/segments`.
            events: >-
              Gives access to all endpoints and methods starting with
              `/v1/events`.
            client_events: >-
              Gives access to all endpoints and methods starting with
              `client/v1/events`.
            rewards: >-
              Gives access to all endpoints and methods starting with
              `/v1/rewards`.
            assets: >-
              Gives access to all endpoints and methods starting with
              `/v1/assets`.
            task-results: >-
              Gives access to all endpoints and methods starting with
              `/v1/task-results`.
            loyalties: >-
              Gives access to all endpoints and methods starting with
              `/v1/loyalties`.
            client_consents: >-
              Gives access to all endpoints and methods starting with
              `client/v1/consents`.
            consents: >-
              Gives access to all endpoints and methods starting with
              `/v1/consents`.
            async-actions: >-
              Gives access to all endpoints and methods starting with
              `/v1/async-actions`.
            product-collections: >-
              Gives access to all endpoints and methods starting with
              `/v1/product-collections`.
            categories: >-
              Gives access to all endpoints and methods starting with
              `/v1/categories`.
            metadata-schemas: >-
              Gives access to all endpoints and methods starting with
              `/v1/metadata-schemas`.
            locations: >-
              Gives access to all endpoints and methods starting with
              `/v1/locations`.
            referrals: >-
              Gives access to all endpoints and methods starting with
              `/v1/referrals`.
            trash-bin: >-
              Gives access to all endpoints and methods starting with
              `/v1/trash-bin`.
            templates: >-
              Gives access to all endpoints and methods starting with
              `/v1/templates`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.