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

# Creating a Client

Once you've set your user up to send out invoices, you can easily add the client that your user wishes to bill. This client's information can be easily re-used for future invoices, including keeping a card on file.

## 1. Getting the user's existing clients

First, you should retrieve a list of the user's clients. Be sure to include that user's `access_token` in the headers.

```curl theme={null}
curl \
  --request GET \
  --url https://sandbox.hurdlr.com/rest/v5/clientMgmt/clients \
  --header 'Authorization: Bearer ${access_token}' \
  --header 'Content-Type: application/json' \
```

The response from GET /clients contains an array of the user's clients:

```json theme={null}
[
  {
    "id": 805609,
    "businessId": "416080",
    "name": "Bill Tanner",
    "status": "OPEN",
    "email": "will@hurdlr.com",
    "ccEmails": [],
    "bccEmails": [],
    "lastUpdatedDate": "2020-09-02T21:31:49.000Z"
  }
]
```

## 2. Adding or updating a client

You should update the following fields for any new or existing client:

| Field      | Description                                                                                        | Format                                           |
| :--------- | :------------------------------------------------------------------------------------------------- | :----------------------------------------------- |
| id         | Id of the client record, if this is an update                                                      | Numeric                                          |
| businessId | Id of the business that this should be billed from                                                 | String                                           |
| name       | Name of the client                                                                                 | Any string                                       |
| status     | Status of the client; use "OPEN" in most cases                                                     | Must be one of the following: "OPEN", "ARCHIVED" |
| email      | Client's email address; new invoices created for this client will be sent to this email by default | Well-formatted string                            |
| ccEmails   | Emails that should be cc'ed on invoices created for this client by default                         | Array of strings                                 |
| bccEmails  | Emails that should be bcc'ed on invoices created for this client by default                        | Array of strings                                 |

To add or update a client, simply POST the client's JSON object to the /client endpoint:

```curl theme={null}
curl \
  --request POST \
  --url https://sandbox.hurdlr.com/rest/v5/clientMgmt/client \
  --header 'Authorization: Bearer ${access_token}' \
  --header 'Content-Type: application/json' \
  --data '{
    "businessId": "416080",
    "name": "Joe the Client",
    "status": "OPEN",
    "email": "their_client@their_domain.com",
    "ccEmails": [],
    "bccEmails": []
  }'
```
