For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.prolifi.io/endpoints/customers/llms.txt. For full documentation content, see https://docs.prolifi.io/endpoints/customers/llms-full.txt.

# Create a customer

POST https://api.prolifi.co/api/v1/public/customers
Content-Type: application/json

Creates a new customer record. The `email` field is required. You can provide a full `name` (which will be split into `first_name` and `last_name`) or provide them separately.

If `company_name` is provided, the customer type is automatically set to `business`.


Reference: https://docs.prolifi.io/endpoints/customers/create-customer

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Prolifi Public API
  version: 1.0.0
paths:
  /customers:
    post:
      operationId: create-customer
      summary: Create a customer
      description: >
        Creates a new customer record. The `email` field is required. You can
        provide a full `name` (which will be split into `first_name` and
        `last_name`) or provide them separately.


        If `company_name` is provided, the customer type is automatically set to
        `business`.
      tags:
        - subpackage_customers
      parameters:
        - name: Authorization
          in: header
          description: >
            Use a secret key (`sk_test_*` or `sk_live_*`) for full read/write
            access, or a public key (`pk_test_*` or `pk_live_*`) for read-only
            access.
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Customer created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customers_createCustomer_Response_201'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCustomerRequest'
servers:
  - url: https://api.prolifi.co/api/v1/public
  - url: https://sandbox.prolifi.co/api/v1/public
components:
  schemas:
    CreateCustomerRequestMetadata:
      type: object
      properties: {}
      title: CreateCustomerRequestMetadata
    CreateCustomerRequest:
      type: object
      properties:
        email:
          type: string
          format: email
          description: Customer email address.
        name:
          type:
            - string
            - 'null'
          description: >-
            Full name. Will be split into `first_name` and `last_name` if those
            are not provided separately.
        first_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        company_name:
          type:
            - string
            - 'null'
          description: If provided, customer type is set to `business`.
        external_id:
          type:
            - string
            - 'null'
          description: >-
            Your application's unique identifier for this customer. Used for
            lookups via `GET /customers/{external_id}`.
        phone:
          type:
            - string
            - 'null'
        country_id:
          type:
            - string
            - 'null'
          format: uuid
        metadata:
          oneOf:
            - $ref: '#/components/schemas/CreateCustomerRequestMetadata'
            - type: 'null'
      required:
        - email
      title: CreateCustomerRequest
    CustomerStatus:
      type: string
      enum:
        - active
        - archived
      title: CustomerStatus
    CustomerMetadata:
      type: object
      properties: {}
      title: CustomerMetadata
    Customer:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier.
        external_id:
          type:
            - string
            - 'null'
          description: Your application's identifier for this customer.
        email:
          type: string
          format: email
          description: Email address.
        name:
          type:
            - string
            - 'null'
          description: Full name (computed from first and last name).
        first_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        company_name:
          type:
            - string
            - 'null'
          description: Company name (for business customers).
        phone:
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/CustomerStatus'
        country:
          type:
            - string
            - 'null'
          description: Country name.
        country_id:
          type:
            - string
            - 'null'
          format: uuid
        metadata:
          oneOf:
            - $ref: '#/components/schemas/CustomerMetadata'
            - type: 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      title: Customer
    Customers_createCustomer_Response_201:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Customer'
      title: Customers_createCustomer_Response_201
    ErrorResponseErrorType:
      type: string
      enum:
        - authentication_error
        - permission_error
        - validation_error
        - not_found
        - invalid_request
        - rate_limit_error
        - ip_restricted
        - conflict
        - api_error
      description: Machine-readable error type.
      title: ErrorResponseErrorType
    ErrorResponseErrorErrorsItems:
      type: object
      properties:
        field:
          type: string
          description: The field that failed validation.
        message:
          type: string
          description: The validation error message.
      title: ErrorResponseErrorErrorsItems
    ErrorResponseError:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ErrorResponseErrorType'
          description: Machine-readable error type.
        message:
          type: string
          description: Human-readable error description.
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ErrorResponseErrorErrorsItems'
          description: >-
            Field-level validation errors (only present for `validation_error`
            type).
      required:
        - type
        - message
      title: ErrorResponseError
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorResponseError'
      title: ErrorResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >
        Use a secret key (`sk_test_*` or `sk_live_*`) for full read/write
        access, or a public key (`pk_test_*` or `pk_live_*`) for read-only
        access.

```

## SDK Code Examples

```python Create a business customer
import requests

url = "https://api.prolifi.co/api/v1/public/customers"

payload = {
    "email": "billing@acmecorp.com",
    "first_name": "Jane",
    "last_name": "Smith",
    "company_name": "Acme Corporation",
    "external_id": "org_67890",
    "phone": "+2348012345678"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Create a business customer
const url = 'https://api.prolifi.co/api/v1/public/customers';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"billing@acmecorp.com","first_name":"Jane","last_name":"Smith","company_name":"Acme Corporation","external_id":"org_67890","phone":"+2348012345678"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Create a business customer
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.prolifi.co/api/v1/public/customers"

	payload := strings.NewReader("{\n  \"email\": \"billing@acmecorp.com\",\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Smith\",\n  \"company_name\": \"Acme Corporation\",\n  \"external_id\": \"org_67890\",\n  \"phone\": \"+2348012345678\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Create a business customer
require 'uri'
require 'net/http'

url = URI("https://api.prolifi.co/api/v1/public/customers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"email\": \"billing@acmecorp.com\",\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Smith\",\n  \"company_name\": \"Acme Corporation\",\n  \"external_id\": \"org_67890\",\n  \"phone\": \"+2348012345678\"\n}"

response = http.request(request)
puts response.read_body
```

```java Create a business customer
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolifi.co/api/v1/public/customers")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"billing@acmecorp.com\",\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Smith\",\n  \"company_name\": \"Acme Corporation\",\n  \"external_id\": \"org_67890\",\n  \"phone\": \"+2348012345678\"\n}")
  .asString();
```

```php Create a business customer
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolifi.co/api/v1/public/customers', [
  'body' => '{
  "email": "billing@acmecorp.com",
  "first_name": "Jane",
  "last_name": "Smith",
  "company_name": "Acme Corporation",
  "external_id": "org_67890",
  "phone": "+2348012345678"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Create a business customer
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/customers");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"billing@acmecorp.com\",\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Smith\",\n  \"company_name\": \"Acme Corporation\",\n  \"external_id\": \"org_67890\",\n  \"phone\": \"+2348012345678\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create a business customer
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "email": "billing@acmecorp.com",
  "first_name": "Jane",
  "last_name": "Smith",
  "company_name": "Acme Corporation",
  "external_id": "org_67890",
  "phone": "+2348012345678"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolifi.co/api/v1/public/customers")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

```python
import requests

url = "https://api.prolifi.co/api/v1/public/customers"

payload = {
    "email": "john@example.com",
    "name": "John Doe",
    "external_id": "user_12345",
    "country_id": "d290f1ee-6c54-4b01-90e6-d701748f0851"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.prolifi.co/api/v1/public/customers';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"john@example.com","name":"John Doe","external_id":"user_12345","country_id":"d290f1ee-6c54-4b01-90e6-d701748f0851"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.prolifi.co/api/v1/public/customers"

	payload := strings.NewReader("{\n  \"email\": \"john@example.com\",\n  \"name\": \"John Doe\",\n  \"external_id\": \"user_12345\",\n  \"country_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.prolifi.co/api/v1/public/customers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"email\": \"john@example.com\",\n  \"name\": \"John Doe\",\n  \"external_id\": \"user_12345\",\n  \"country_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolifi.co/api/v1/public/customers")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"john@example.com\",\n  \"name\": \"John Doe\",\n  \"external_id\": \"user_12345\",\n  \"country_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolifi.co/api/v1/public/customers', [
  'body' => '{
  "email": "john@example.com",
  "name": "John Doe",
  "external_id": "user_12345",
  "country_id": "d290f1ee-6c54-4b01-90e6-d701748f0851"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/customers");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"john@example.com\",\n  \"name\": \"John Doe\",\n  \"external_id\": \"user_12345\",\n  \"country_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "email": "john@example.com",
  "name": "John Doe",
  "external_id": "user_12345",
  "country_id": "d290f1ee-6c54-4b01-90e6-d701748f0851"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolifi.co/api/v1/public/customers")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```