# User API

## Create a User

<mark style="color:green;">`POST`</mark> `https://www.cotter.app/api/v0/user/create`

Create a User during registration

#### Headers

| Name         | Type   | Description       |
| ------------ | ------ | ----------------- |
| API\_KEY\_ID | string | Your `API_KEY_ID` |
| Content-Type | string | application/json  |

#### Request Body

| Name       | Type   | Description                                                       |
| ---------- | ------ | ----------------------------------------------------------------- |
| identifier | string | An identifier for the user, like email, phone number, or username |

{% tabs %}
{% tab title="200 The newly created User object in Cotter's server" %}

```javascript
{
  "ID": "abcdefgh-bc20-4ccb-afdf-7fe16c061b30", // [Deprecated] Cotter User ID
  "client_user_id": "abcdefgh-bc20-4ccb-afdf-7fe16c061b30", // [Deprecated]
  "created_at": "2020-08-01T05:55:57.480314022Z",
  "default_method": null,
  "deleted_at": "0001-01-01T00:00:00Z",
  "enrolled": [],
  "identifier": "hello@gmail.com",
  "identifiers": null,
  "issuer": "<YOUR API KEY ID>i",
  "updated_at": "2020-08-01T05:55:57.480314368Z"
}
```

{% endtab %}
{% endtabs %}

Example Curl Request:

```
curl -XPOST \
-H 'API_KEY_ID: <your API KEY ID>' \
-H "Content-Type: application/json" \
-d '{"identifier": "hello@gmail.com"}' \
'https://www.cotter.app/api/v0/user/create'
```

## Get User

<mark style="color:blue;">`GET`</mark> `https://www.cotter.app/api/v0/user?identifier=<identifier>`

Get a `User` object using your user's identifier.

#### Query Parameters

| Name       | Type   | Description                                                                                       |
| ---------- | ------ | ------------------------------------------------------------------------------------------------- |
| identifier | string | The identifier for the user, like the email, phone, or username that was used to create the user. |

#### Headers

| Name         | Type   | Description       |
| ------------ | ------ | ----------------- |
| API\_KEY\_ID | string | Your `API_KEY_ID` |

{% tabs %}
{% tab title="200 If your user has enrolled TRUSTED\_DEVICE , you'll get the following response" %}

```javascript
{
  "ID": "abcdefgh-bc20-4ccb-afdf-7fe16c061b30", // [Deprecated] Cotter User ID
  "client_user_id": "abcdefgh-bc20-4ccb-afdf-7fe16c061b30", // [Deprecated]
  "created_at": "2020-08-01T05:55:57.480314022Z",
  "default_method": "TRUSTED_DEVICE",
  "deleted_at": "0001-01-01T00:00:00Z",
  "enrolled": ["TRUSTED_DEVICE"],
  "identifier": "hello@gmail.com",
  "identifiers": null,
  "issuer": "<YOUR API KEY ID>i",
  "updated_at": "2020-08-01T05:55:57.480314368Z"
}
```

{% endtab %}
{% endtabs %}

## Get All Users

<mark style="color:blue;">`GET`</mark> `https://www.cotter.app/api/v0/user/list?page=0`

Get a list of `Users` that is registered under your API Key. This endpoint is paginated, each page returns 50 records, ordered by `created_at` descendant (newest user shows up first)

#### Query Parameters

| Name | Type   | Description                                                                                                                             |
| ---- | ------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| page | number | The page number that you want to access. Page numbers start from 0. Each page retrieves 50 records, ordered by `created_at` descendant. |

#### Headers

| Name             | Type   | Description           |
| ---------------- | ------ | --------------------- |
| API\_SECRET\_KEY | string | Your `API_SECRET_KEY` |
| API\_KEY\_ID     | string | Your `API_KEY_ID`     |

{% tabs %}
{% tab title="200 A list of the User Object." %}

```javascript
[
  {
    "ID": "jklmnopqr-abcd-abcd-abcd-1168d4b38d0d", // [Deprecated] Cotter User ID
    "created_at": "0001-01-01T00:00:00Z",
    "updated_at": "0001-01-01T00:00:00Z",
    "deleted_at": "0001-01-01T00:00:00Z",
    "issuer": "abcdefgh-abcd-abcd-abcd-f901315ad31b",
    "client_user_id": "jklmnopqr-abcd-abcd-abcd-1168d4b38d0d",
    "enrolled": [],
    "default_method": null,
    "identifier": "team1@cotter.app",
    "identifiers": null
  },
  {
    "ID": "stuvxyza-abcd-abcd-abcd-6eb4c013e610", // [Deprecated] Cotter User ID
    "created_at": "0001-01-01T00:00:00Z",
    "updated_at": "0001-01-01T00:00:00Z",
    "deleted_at": "0001-01-01T00:00:00Z",
    "issuer": "abcdefgh-abcd-abcd-abcd-f901315ad31b",
    "client_user_id": "stuvxyza-abcd-abcd-abcd-6eb4c013e610",
    "enrolled": [],
    "default_method": null,
    "identifier": "team2@cotter.app",
    "identifiers": null
  },
  {
    "ID": "abcdefgh-abcd-abcd-abcd-22bc178867ef", // [Deprecated] Cotter User ID
    "created_at": "0001-01-01T00:00:00Z",
    "updated_at": "2020-07-21T02:42:16.318885Z",
    "deleted_at": "0001-01-01T00:00:00Z",
    "issuer": "abcdefgh-abcd-abcd-abcd-f901315ad31b",
    "client_user_id": "bdabcdefgh-abcd-abcd-abcd-22bc178867ef",
    "enrolled": [
      "WEBAUTHN"
    ],
    "default_method": "WEBAUTHN",
    "identifier": "team@cotter.app",
    "identifiers": null
  }
]
```

{% endtab %}
{% endtabs %}


---

# 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.cotter.app/api-reference/user-api.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.
