# API: Clients

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/work/clients` | Your clients | `projects:read` |
| POST | `/v1/work/clients` | Add a client | `projects:write` |
| DELETE | `/v1/work/clients/:id` | Remove a client added by mistake. One with projects is archived instead | `projects:write` |
| GET | `/v1/work/clients/:id` | One client, with who to write to | `projects:read` |
| PATCH | `/v1/work/clients/:id` | Correct a client, archive it or bring it back. Its projects and time stay | `projects:write` |
| POST | `/v1/work/clients/:id/contacts` | Add someone to write to at a client | `projects:write` |
| DELETE | `/v1/work/clients/:id/contacts/:contact_id` | Remove a client's contact | `projects:write` |
| PATCH | `/v1/work/clients/:id/contacts/:contact_id` | Correct a client's contact | `projects:write` |
| PUT | `/v1/work/clients/:id/link` | Make a page for a client with their invoices and payments, or turn it off. A new link stops the old one | `invoices:write` |
| PUT | `/v1/work/clients/:id/rates` | Set what an hour costs this client: for everyone, or for a person or a task. A project's own rate comes first. Billed time never changes | `projects:write` |

## Examples

### GET /v1/work/clients

Your clients

```bash
curl -s "https://api.hourfinch.com/v1/work/clients" \
  -H "Authorization: Bearer $TK_API_KEY"
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}` },
});
const data = await res.json();
```

### POST /v1/work/clients

Add a client

```bash
curl -s -X POST "https://api.hourfinch.com/v1/work/clients" \
  -H "Authorization: Bearer $TK_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### DELETE /v1/work/clients/$ID

Remove a client added by mistake. One with projects is archived instead

```bash
curl -s -X DELETE "https://api.hourfinch.com/v1/work/clients/$ID" \
  -H "Authorization: Bearer $TK_API_KEY"
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients/${id}`, {
  method: "DELETE",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/work/clients/$ID

One client, with who to write to

```bash
curl -s "https://api.hourfinch.com/v1/work/clients/$ID" \
  -H "Authorization: Bearer $TK_API_KEY"
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients/${id}`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}` },
});
const data = await res.json();
```

### PATCH /v1/work/clients/$ID

Correct a client, archive it or bring it back. Its projects and time stay

```bash
curl -s -X PATCH "https://api.hourfinch.com/v1/work/clients/$ID" \
  -H "Authorization: Bearer $TK_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients/${id}`, {
  method: "PATCH",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### POST /v1/work/clients/$ID/contacts

Add someone to write to at a client

```bash
curl -s -X POST "https://api.hourfinch.com/v1/work/clients/$ID/contacts" \
  -H "Authorization: Bearer $TK_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients/${id}/contacts`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### DELETE /v1/work/clients/$ID/contacts/$CONTACT_ID

Remove a client's contact

```bash
curl -s -X DELETE "https://api.hourfinch.com/v1/work/clients/$ID/contacts/$CONTACT_ID" \
  -H "Authorization: Bearer $TK_API_KEY"
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients/${id}/contacts/${contact_id}`, {
  method: "DELETE",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}` },
});
const data = await res.json();
```

### PATCH /v1/work/clients/$ID/contacts/$CONTACT_ID

Correct a client's contact

```bash
curl -s -X PATCH "https://api.hourfinch.com/v1/work/clients/$ID/contacts/$CONTACT_ID" \
  -H "Authorization: Bearer $TK_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients/${id}/contacts/${contact_id}`, {
  method: "PATCH",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### PUT /v1/work/clients/$ID/link

Make a page for a client with their invoices and payments, or turn it off. A new link stops the old one

```bash
curl -s -X PUT "https://api.hourfinch.com/v1/work/clients/$ID/link" \
  -H "Authorization: Bearer $TK_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients/${id}/link`, {
  method: "PUT",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### PUT /v1/work/clients/$ID/rates

Set what an hour costs this client: for everyone, or for a person or a task. A project's own rate comes first. Billed time never changes

```bash
curl -s -X PUT "https://api.hourfinch.com/v1/work/clients/$ID/rates" \
  -H "Authorization: Bearer $TK_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.hourfinch.com/v1/work/clients/${id}/rates`, {
  method: "PUT",
  headers: { authorization: `Bearer ${process.env.TK_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

Request and response schemas: [https://www.hourfinch.com/openapi.json](https://www.hourfinch.com/openapi.json). All resources: [API reference](https://www.hourfinch.com/docs/api).
