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

# Create a customer



## OpenAPI

````yaml post /customers
openapi: 3.0.0
info:
  title: Customer API
  version: v1
servers:
  - url: https://sandbox-api.fedapay.com/v1
  - url: https://api.fedapay.com/v1
security: []
paths:
  /customers:
    post:
      summary: Create a customer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                  description: Customer's email address.
                phone_number:
                  type: object
                  description: Customer's phone number.
                  properties:
                    number:
                      type: integer
                      description: Phone number without national prefix.
                    country:
                      type: string
                      description: Country code.
                firstname:
                  type: string
                  description: Customer's first name.
                lastname:
                  type: string
                  description: Customer's last name.
              anyOf:
                - required:
                    - email
                - required:
                    - phone_number
      responses:
        '201':
          description: Customer created successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Customer ID.
                  firstname:
                    type: string
                    description: Customer's first name.
                  lastname:
                    type: string
                    description: Customer's last name.
                  full_name:
                    type: string
                    description: Customer's full name.
                  email:
                    type: string
                    format: email
                    description: Customer's email address.
                  account_id:
                    type: integer
                    description: ID of the customer's account.
                  phone_number_id:
                    type: integer
                    description: ID of the customer's phone number.
                  created_at:
                    type: string
                    format: date-time
                    description: Date and time of customer creation.
                  updated_at:
                    type: string
                    format: date-time
                    description: Date and time of last customer update.
                  deleted_at:
                    type: string
                    format: date-time
                    description: Date and time of customer deletion (if applicable).
        '400':
          description: Invalid request body.
        '401':
          description: Unauthorized. Provide a valid secret key.
        '422':
          description: Validation error.
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          label: NodeJs
          source: >-
            const { FedaPay, Customer } = require('fedapay');

            /* Replace YOUR_SECRETE_API_KEY with your real API key */

            FedaPay.setApiKey("YOUR_SECRETE_API_KEY");

            /* Specify whether you want to run your query in test or live mode
            */

            FedaPay.setEnvironment('sandbox'); //or setEnvironment('live');

            /* Create customer */

            const customer = await Customer.create({
              firstname: 'John',
              lastname: 'Doe',
              email: 'john@doe.com',
              phone_number: {
                number: '90090909',
                country: 'BJ'
              }
            });
        - lang: PHP
          source: >-
            /* Replace YOUR_SECRETE_API_KEY with your secret API key */

            \FedaPay\FedaPay::setApiKey("YOUR_SECRETE_API_KEY");

            /* Specify whether you want to run your query in test or live mode
            */

            \FedaPay\FedaPay::setEnvironment('sandbox'); //or
            setEnvironment('live');

            /* Create customer */

            \FedaPay\Customer::create(array(
              "firstname" => "John",
              "lastname" => "Doe",
              "email" => "John.doe@gmail.com",
              "phone_number" => [
                "number" => "+22966666600",
                "country" => 'bj' // 'bj' Benin code
              ]
            ));
        - lang: Ruby
          source: |-
            require 'fedapay';
            # configure FedaPay library
            FedaPay.api_key = '' # Your secret api key
            FedaPay.environment = '' # sandbox or live
            phone = {
              country: 'bj',
              number: '66000001'
            };
            customer = FedaPay::Customer.create(
              firstname: 'firstname',
              lastname: 'lastname',
              email: 'email@test.com',
              phone_number: phone
            );
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````