> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.afternoon.co/llms.txt.
> For full documentation content, see https://docs.afternoon.co/llms-full.txt.

# Create a customer

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

Creates a new customer for the authenticated company.

Reference: https://docs.afternoon.co/api-reference/afternoon-events-api/customers/create

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Afternoon Events API
  version: 1.0.0
paths:
  /v1/customers:
    post:
      operationId: create
      summary: Create a customer
      description: Creates a new customer for the authenticated company.
      tags:
        - subpackage_customers
      parameters:
        - name: Authorization
          in: header
          description: API key obtained from the Afternoon dashboard
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Customer created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCustomerRequest'
servers:
  - url: https://api.afternoon.co
  - url: http://localhost:8787
components:
  schemas:
    CreateCustomerRequestBillingAddress:
      type: object
      properties:
        country:
          type: string
          description: Two-letter ISO country code
        state:
          type: string
          description: State or province
        city:
          type: string
          description: City name
        street:
          type: string
          description: Street address line 1
        street2:
          type: string
          description: Street address line 2
        zip:
          type: string
          description: Postal / ZIP code
      description: Billing address
      title: CreateCustomerRequestBillingAddress
    CreateCustomerRequestShippingAddress:
      type: object
      properties:
        country:
          type: string
          description: Two-letter ISO country code
        state:
          type: string
          description: State or province
        city:
          type: string
          description: City name
        street:
          type: string
          description: Street address line 1
        street2:
          type: string
          description: Street address line 2
        zip:
          type: string
          description: Postal / ZIP code
      description: Shipping address
      title: CreateCustomerRequestShippingAddress
    CreateCustomerRequest:
      type: object
      properties:
        name:
          type: string
          description: Business or display name
        first_name:
          type: string
          description: Contact first name
        last_name:
          type: string
          description: Contact last name
        email:
          type: string
          format: email
          description: Primary email address
        phone:
          type: string
          description: Phone number
        url:
          type: string
          format: uri
          description: Website URL
        external_id:
          type: string
          description: Your internal identifier for this customer
        billing_address:
          $ref: '#/components/schemas/CreateCustomerRequestBillingAddress'
          description: Billing address
        shipping_address:
          $ref: '#/components/schemas/CreateCustomerRequestShippingAddress'
          description: Shipping address
      title: CreateCustomerRequest
    CustomerBillingAddress:
      type: object
      properties:
        country:
          type: string
          description: Two-letter ISO country code
        state:
          type: string
          description: State or province
        city:
          type: string
          description: City name
        street:
          type: string
          description: Street address line 1
        street2:
          type: string
          description: Street address line 2
        zip:
          type: string
          description: Postal / ZIP code
      description: Billing address
      title: CustomerBillingAddress
    CustomerShippingAddress:
      type: object
      properties:
        country:
          type: string
          description: Two-letter ISO country code
        state:
          type: string
          description: State or province
        city:
          type: string
          description: City name
        street:
          type: string
          description: Street address line 1
        street2:
          type: string
          description: Street address line 2
        zip:
          type: string
          description: Postal / ZIP code
      description: Shipping address
      title: CustomerShippingAddress
    Customer:
      type: object
      properties:
        id:
          type: string
        name:
          type:
            - string
            - 'null'
        first_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        email:
          type:
            - string
            - 'null'
        phone:
          type:
            - string
            - 'null'
        url:
          type:
            - string
            - 'null'
        external_id:
          type:
            - string
            - 'null'
        billing_address:
          oneOf:
            - $ref: '#/components/schemas/CustomerBillingAddress'
            - type: 'null'
          description: Billing address
        shipping_address:
          oneOf:
            - $ref: '#/components/schemas/CustomerShippingAddress'
            - type: 'null'
          description: Shipping address
        created_at:
          type: string
          description: ISO 8601 creation timestamp
        updated_at:
          type: string
          description: ISO 8601 last-updated timestamp
      required:
        - id
        - name
        - first_name
        - last_name
        - email
        - phone
        - url
        - external_id
        - billing_address
        - shipping_address
        - created_at
        - updated_at
      title: Customer
    CustomerResponse:
      type: object
      properties:
        success:
          type: boolean
        customer:
          $ref: '#/components/schemas/Customer'
        request_id:
          type: string
      required:
        - success
        - customer
        - request_id
      title: CustomerResponse
    ErrorResponseError:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        details:
          oneOf:
            - description: Any type
            - type: 'null'
      required:
        - code
        - message
      title: ErrorResponseError
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
        error:
          $ref: '#/components/schemas/ErrorResponseError'
        request_id:
          type: string
          description: Request ID for tracing
      required:
        - success
        - error
      title: ErrorResponse
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key obtained from the Afternoon dashboard

```

## SDK Code Examples

```typescript
import { AfternoonClient } from "afternoon-sdk";

async function main() {
    const client = new AfternoonClient({
        token: "YOUR_TOKEN_HERE",
    });
    await client.customers.create({});
}
main();

```

```python
import requests

url = "https://api.afternoon.co/v1/customers"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```go
package main

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

func main() {

	url := "https://api.afternoon.co/v1/customers"

	payload := strings.NewReader("{}")

	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.afternoon.co/v1/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 = "{}"

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.afternoon.co/v1/customers")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.afternoon.co/v1/customers', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.afternoon.co/v1/customers");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.afternoon.co/v1/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()
```