# The Clockwork API

## Getting Started

In order to use the Clockwork API, you'll need an API token. Contact us for one. Once you have it, it'll look something like this: `WHICv_xM.SFMyNTY.g3QAAAACZAAEZGF0YWEBZAAGc2lnbmVkbgYA21AjlnIB.J2z-zY3HYRBoKOwGI-qZkfAmChlC4lO9HxxJ_u5RlIA`

In order to make requests to the API, you'll need to put your API token in your request `Authorization` header. It'll look something like this:

```
{
    "Authorization": "Bearer <api_token>"
}
```

Once that's set up, you're ready to start using the API!

## Create/Update customer

<mark style="color:green;">`POST`</mark> `https://app.clockworkhq.com/api/v1/customers`

This endpoint allows you to create or update a customer. We key each customer by the email address supplied in the body parameters. If a customer already exists, we will update their name (first and last), and their attributes

#### Headers

| Name          | Type   | Description                                                         |
| ------------- | ------ | ------------------------------------------------------------------- |
| Authorization | string | Api authentication token. Should be in the form of Bearer: \<token> |

#### Request Body

| Name        | Type   | Description                                                                                                                      |
| ----------- | ------ | -------------------------------------------------------------------------------------------------------------------------------- |
| email       | string |                                                                                                                                  |
| full\_name  | string | <p>The customer's full name as a single<br>string, e.g. "Brønt Chloaf." We will parse this out as first\_name and last\_name</p> |
| first\_name | string | The customer's first name                                                                                                        |
| last\_name  | string | The customer's last name                                                                                                         |

{% tabs %}
{% tab title="200 Customer successfully created or updated" %}

```
{message: "Success"}
```

{% endtab %}

{% tab title="401 This usually means the API key was invalid or not found in the request headers" %}

```
{"message": "Could not validate - API key may be malformed or invalid"}
```

{% endtab %}

{% tab title="500 Something bad happened on our end :(" %}

```
{"message": "Error - customer was not created. Reason: <error_reason>"}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Any additional parameters you add to the body other than `first_name, last_name, full_name,` and `email` will be automatically added to the list of the customer's attributes.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clockworkhq.com/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
