---
page_source: https://docs.juspay.io/agoda-integration/docs/customer/get-or-create-customer
page_title: Get or Create Customer
---

## API Version: default


# Get or Create Customer API



Get or Create a new customer object. You may invoke this method whenever someone registers in your website or App. You can use customer ID sent by you or JusPay will respond with an ID that you can persist in your Database. Pass this ID at the time of order creation to ensure proper linking of orders/payments belonging to a customer.## Endpoints:
- Production: https://api.juspay.in/v2/customers

## Request Type: 
POST

## Content-Type: 
application/json

## Authorization:

#### Basic Auth:
Consists of two parts.

* Username: API Key obtained from Juspay dashboard
* Password: Empty string
- Value: <p>Example:- <br> Basic MUQ2QUxxxxxxxxxxxxU5QTIxQzNFNTQwNkFDMEZCOg==</p>
- Tags: Base64 Encoded username:password, required
## Headers:

#### x-merchantid:
Merchant ID provided by Juspay
- Value: <p>Example:- <br>merchant_id</p>
- Tags: string, required

#### Content-Type:
application/x-www-form-urlencoded
- Tags: String, Mandatory
## Sample Code Snippets:
### Sample Request:

#### Request Code Snippet:

```request
curl -X POST https://api.juspay.in/v2/customers\
-u your_api_key:\
-H 'x-merchantid: merchant_id'\
-H 'Content-Type: application/x-www-form-urlencoded'\
-d "object_reference_id=customer@gmail.com"\
-d "mobile_number=99887766"\    
-d "email_address=customer@gmail.com"\
-d "first_name=John"\
-d "last_name=Smith"\
-d "mobile_country_code=65"\
-d"options.get_client_auth_token=true"\

```

### Sample Response:

#### Without Client Auth Token:
```json
{
  "id": "cst_pcxaymwoh9vbse97",
  "object": "customer",
  "object_reference_id": "customer@gmail.com",
  "mobile_country_code": "65",
  "mobile_number": "99887766",
  "email_address": "customer@gmail.com",
  "first_name": "John",
  "last_name": "Smith",
  "date_created": "2020-03-17T14:16:31Z",
  "last_updated": "2020-03-17T14:16:31Z"
}
```

#### With Client Auth Token:
```json
{
  "id": "cst_afdeuvmfhs3j1acm",
  "object": "customer",
  "object_reference_id": "customer@gmail.com",
  "mobile_country_code": "65",
  "mobile_number": "99887766",
  "email_address": "customer@gmail.com",
  "first_name": "John",
  "last_name": "Smith",
  "date_created": "2020-03-17T14:13:37Z",
  "last_updated": "2020-03-17T14:13:37Z",
  "juspay": {
    "client_auth_token": "tkn_24543c6a278f45d680d09edb32e78061",
    "client_auth_token_expiry": "2020-03-17T14:28:37Z"
  }
}
```

## Body Parameters:
### Basic Parameters:

#### object_reference_id:
- Description: Unique ID that you use to represent the customer in your database. This must be atleast 8 characters and must be unique. The typical value for this field would be email address or mobile number or auto increment ID that you have in your DB.
- Value: <p>Example:- <br> customer-id-007 </p>
- Tags: string, required

#### mobile_number:
- Description: Customers mobile number. We recommend passing only the 10 digit number without appending "+" or mobile country code.
- Tags: string, required

#### email_address:
- Description: Email address of the customer. If the backend gateway requires it, then you must send this value.**Constraints :** You are allowed to use alphanumeric characters and the following special characters:`!#$%&'*+-/=?^_.{|}~`@`

`_`and `.` cannot appear at the beginning or end of the local part of the email address (before and after the `@`symbol).
- Tags: string

#### first_name:
- Description: First Name of customer. This value will be used for customer identification.**Constraints :** You are allowed to use alphanumeric characters and the following special characters: `().-_`
- Tags: string

#### last_name:
- Description: Last Name of customer. This value will be used for customer identification.**Constraints :** You are allowed to use alphanumeric characters and the following special characters: `().-_`
- Tags: string

#### mobile_country_code:
- Description: Mobile country code. No need to prefix +.
- Tags: string

#### options.get_client_auth_token:
- Description: This is required to obtain the client_auth_token which is used for SDK integration

Value: true | false
- Tags: Boolean
## API Responses:
### 200:

#### WITHOUT CLIENT_AUTH_TOKEN:
- Value:
  - **Id**:
    - Tags: string
  - **Customer_id**:
    - Description: It is the ID with which merchant refers to a customer object. This id is used to access the stored payment methods, allow EMI transactions and setup subscriptions.
    - Tags: string
  - **Object**:
    - Tags: string
  - **Mobile_number**:
    - Description: Customers mobile number
    - Tags: string
  - **Mobile_country_code**:
    - Description: Cusomter's mobile country code
    - Tags: string
  - **Last_updated**:
    - Tags: string
  - **Last_name**:
    - Description: Customer's last name
    - Tags: string
  - **First_name**:
    - Description: Customer's first name
    - Tags: string
  - **Email_address**:
    - Description: Customer's e-mail address
    - Tags: string
  - **Date_created**:
    - Tags: string
- Tags: JSON

#### WITH CLIENT_AUTH_TOKEN:
- Value:
  - **Id**:
    - Tags: string
  - **Customer_id**:
    - Description: It is the ID with which merchant refers to a customer object. This id is used to access the stored payment methods, allow EMI transactions and setup subscriptions.
    - Tags: string
  - **Object**:
    - Tags: string
  - **Mobile_number**:
    - Description: Customers mobile number
    - Tags: string
  - **Mobile_country_code**:
    - Description: Cusomter's mobile country code
    - Tags: string
  - **Last_updated**:
    - Tags: string
  - **Last_name**:
    - Description: Customer's last name
    - Tags: string
  - **First_name**:
    - Description: Customer's first name
    - Tags: string
  - **Email_address**:
    - Description: Customer's e-mail address
    - Tags: string
  - **Date_created**:
    - Tags: string
  - **Juspay**:
    - Value:
      - **Client_auth_token_expiry**:
        - Tags: string
      - **Client_auth_token**:
        - Tags: string
    - Tags: JSON
- Tags: JSON
### 400:

#### status:
- Description: Bad Request
- Tags: string

#### error_code:
- Description: Details of keys missing
- Value: <p>Example:- <br> Mandatory fields are missing </p>
- Tags: string

#### error_message:
- Description: Further Details of keys missing
- Tags: string
