# Customers

> Markdown edition of https://api.fiz.co/docs/api/customers. Português: https://api.fiz.co/docs/api/customers.md?lang=pt. Index: https://api.fiz.co/llms.txt

The customers you invoice. A document references one by id. 6 operations.

## List customers

GET `/customers`

Returns a paginated, filterable list of customers. By default returns 20 customers starting at offset 0.

Authentication: an API key (`x-api-key`) or an OAuth access token.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `offset` | query | number | Number of records to skip (offset) |
| `limit` | query | number | Maximum number of records to return |
| `sort` | query | string | Sort field and order (e.g. name:asc, city:desc) |
| `search` | query | string | Global search term |
| `taxpayerNumber` | query | string | Filter by tax number (NIF) |
| `name` | query | string | Filter by name |
| `firstName` | query | string | Filter by first name |
| `lastName` | query | string | Filter by last name |
| `companyName` | query | string | Filter by company name |
| `companyPosition` | query | string | Filter by position in the company |
| `email` | query | string | Filter by email |
| `website` | query | string | Filter by website |
| `description` | query | string | Filter by description |
| `address` | query | string | Filter by address |
| `postalCode` | query | string | Filter by postal code |
| `country` | query | string | Filter by country |
| `phone` | query | string | Filter by phone |
| `fax` | query | string | Filter by fax |
| `mobile` | query | string | Filter by mobile phone |
| `city` | query | string | Filter by city |
| `system` | query | boolean | Filter by system type |
| `isArchived` | query | boolean | Filter by archived status |

**curl**

```shell
curl 'https://api.fiz.co/customers' \
  --header "x-api-key: $FIZ_API_KEY"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.customers.list();
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.customers.list()
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->customers->list();
```

### Response `200`

List of customers returned successfully

| Field | Type | Description |
| --- | --- | --- |
| `[].id` | string | Unique customer identifier |
| `[].taxpayerNumber` | string · can be null | Tax number (NIF) |
| `[].name` | string · can be null | Customer name |
| `[].photo` | string · can be null | Photo URL |
| `[].companyName` | string · can be null | Company name |
| `[].companyPosition` | string · can be null | Position in the company |
| `[].email` | string · can be null | Customer email |
| `[].website` | string · can be null | Website |
| `[].description` | string · can be null | Description |
| `[].address` | string · can be null | Address |
| `[].postalCode` | string · can be null | Postal code |
| `[].country` | string · can be null | Country code |
| `[].phone` | string · can be null | Phone |
| `[].fax` | string · can be null | Fax |
| `[].mobile` | string · can be null | Mobile phone |
| `[].city` | string · can be null | City |
| `[].isArchived` | boolean · can be null | Whether the customer is archived. An archived customer is left out of the default listing and can be restored with POST /customers/{id}/restore. |

### Errors

-   `400` Invalid parameters
-   `401` Unauthorized - API key missing or invalid
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Create customer

POST `/customers`

Creates a new customer in the system

Authentication: an API key (`x-api-key`) or an OAuth access token. Send an `Idempotency-Key` to retry this call safely.

### Request body

Data required to create the customer

| Field | Type | Description |
| --- | --- | --- |
| `name` **required** | string | Customer name |
| `firstName` | string | First name |
| `lastName` | string | Last name |
| `email` | string | Customer email |
| `taxpayerNumber` | string | Tax number (NIF) |
| `country` | string | Country code (ISO 3166-1 alpha-2) |
| `phone` | string | Phone |
| `mobile` | string | Mobile phone |
| `fax` | string | Fax |
| `address` | string | Address |
| `city` | string | City |
| `postalCode` | string | Postal code |
| `website` | string | Website |
| `companyName` | string | Company name |
| `companyPosition` | string | Position in the company |
| `description` | string | Description |
| `photo` | string | Photo URL |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
curl --request POST 'https://api.fiz.co/customers' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "name": "João Silva"
}'
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.customers.create({
  name: 'João Silva',
});
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.customers.create({
    "name": "João Silva",
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->customers->create([
    'name' => 'João Silva',
]);
```

### Response `201`

Customer created successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique customer identifier |
| `taxpayerNumber` | string · can be null | Tax number (NIF) |
| `name` | string · can be null | Customer name |
| `photo` | string · can be null | Photo URL |
| `companyName` | string · can be null | Company name |
| `companyPosition` | string · can be null | Position in the company |
| `email` | string · can be null | Customer email |
| `website` | string · can be null | Website |
| `description` | string · can be null | Description |
| `address` | string · can be null | Address |
| `postalCode` | string · can be null | Postal code |
| `country` | string · can be null | Country code |
| `phone` | string · can be null | Phone |
| `fax` | string · can be null | Fax |
| `mobile` | string · can be null | Mobile phone |
| `city` | string · can be null | City |
| `isArchived` | boolean · can be null | Whether the customer is archived. An archived customer is left out of the default listing and can be restored with POST /customers/{id}/restore. |

### Errors

-   `400` Invalid data
-   `401` Unauthorized - API key missing or invalid
-   `409` A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
-   `422` The idempotency key was already used with a different request body
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Get customer by ID

GET `/customers/{id}`

Returns a single customer by its unique identifier

Authentication: an API key (`x-api-key`) or an OAuth access token.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Unique customer identifier |

**curl**

```shell
curl 'https://api.fiz.co/customers/ID' \
  --header "x-api-key: $FIZ_API_KEY"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.customers.retrieve('ID');
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.customers.retrieve("ID")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->customers->retrieve('ID');
```

### Response `200`

Customer found

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique customer identifier |
| `taxpayerNumber` | string · can be null | Tax number (NIF) |
| `name` | string · can be null | Customer name |
| `photo` | string · can be null | Photo URL |
| `companyName` | string · can be null | Company name |
| `companyPosition` | string · can be null | Position in the company |
| `email` | string · can be null | Customer email |
| `website` | string · can be null | Website |
| `description` | string · can be null | Description |
| `address` | string · can be null | Address |
| `postalCode` | string · can be null | Postal code |
| `country` | string · can be null | Country code |
| `phone` | string · can be null | Phone |
| `fax` | string · can be null | Fax |
| `mobile` | string · can be null | Mobile phone |
| `city` | string · can be null | City |
| `isArchived` | boolean · can be null | Whether the customer is archived. An archived customer is left out of the default listing and can be restored with POST /customers/{id}/restore. |

### Errors

-   `400` Invalid ID
-   `401` Unauthorized - API key missing or invalid
-   `404` Customer not found
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Update customer

PATCH `/customers/{id}`

Updates an existing customer

Authentication: an API key (`x-api-key`) or an OAuth access token. Send an `Idempotency-Key` to retry this call safely.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Unique customer identifier |

### Request body

Customer fields to update

| Field | Type | Description |
| --- | --- | --- |
| `name` | string | Customer name |
| `firstName` | string | First name |
| `lastName` | string | Last name |
| `email` | string | Customer email |
| `taxpayerNumber` | string | Tax number (NIF) |
| `country` | string | Country code (ISO 3166-1 alpha-2) |
| `phone` | string | Phone |
| `mobile` | string | Mobile phone |
| `fax` | string | Fax |
| `address` | string | Address |
| `city` | string | City |
| `postalCode` | string | Postal code |
| `website` | string | Website |
| `companyName` | string | Company name |
| `companyPosition` | string | Position in the company |
| `description` | string | Description |
| `photo` | string | Photo URL |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
curl --request PATCH 'https://api.fiz.co/customers/ID' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "name": "João Silva",
  "firstName": "João",
  "lastName": "Silva"
}'
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.customers.update('ID', {
  name: 'João Silva',
  firstName: 'João',
  lastName: 'Silva',
});
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.customers.update("ID", {
    "name": "João Silva",
    "firstName": "João",
    "lastName": "Silva",
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->customers->update('ID', [
    'name' => 'João Silva',
    'firstName' => 'João',
    'lastName' => 'Silva',
]);
```

### Response `200`

Customer updated successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique customer identifier |
| `taxpayerNumber` | string · can be null | Tax number (NIF) |
| `name` | string · can be null | Customer name |
| `photo` | string · can be null | Photo URL |
| `companyName` | string · can be null | Company name |
| `companyPosition` | string · can be null | Position in the company |
| `email` | string · can be null | Customer email |
| `website` | string · can be null | Website |
| `description` | string · can be null | Description |
| `address` | string · can be null | Address |
| `postalCode` | string · can be null | Postal code |
| `country` | string · can be null | Country code |
| `phone` | string · can be null | Phone |
| `fax` | string · can be null | Fax |
| `mobile` | string · can be null | Mobile phone |
| `city` | string · can be null | City |
| `isArchived` | boolean · can be null | Whether the customer is archived. An archived customer is left out of the default listing and can be restored with POST /customers/{id}/restore. |

### Errors

-   `400` Invalid data
-   `401` Unauthorized - API key missing or invalid
-   `409` A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
-   `422` The idempotency key was already used with a different request body
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Archive customer

DELETE `/customers/{id}`

Archives a customer by its unique identifier. The customer is not permanently removed, only marked as archived.

Authentication: an API key (`x-api-key`) or an OAuth access token. Send an `Idempotency-Key` to retry this call safely.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Unique customer identifier |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
curl --request DELETE 'https://api.fiz.co/customers/ID' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.customers.delete('ID');
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.customers.delete("ID")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->customers->delete('ID');
```

### Response `200`

Customer archived successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique customer identifier |
| `taxpayerNumber` | string · can be null | Tax number (NIF) |
| `name` | string · can be null | Customer name |
| `photo` | string · can be null | Photo URL |
| `companyName` | string · can be null | Company name |
| `companyPosition` | string · can be null | Position in the company |
| `email` | string · can be null | Customer email |
| `website` | string · can be null | Website |
| `description` | string · can be null | Description |
| `address` | string · can be null | Address |
| `postalCode` | string · can be null | Postal code |
| `country` | string · can be null | Country code |
| `phone` | string · can be null | Phone |
| `fax` | string · can be null | Fax |
| `mobile` | string · can be null | Mobile phone |
| `city` | string · can be null | City |
| `isArchived` | boolean · can be null | Whether the customer is archived. An archived customer is left out of the default listing and can be restored with POST /customers/{id}/restore. |

### Errors

-   `400` Invalid ID
-   `401` Unauthorized - API key missing or invalid
-   `404` Customer not found
-   `409` A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
-   `422` The idempotency key was already used with a different request body
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Restore archived customer

POST `/customers/{id}/restore`

Restores an archived customer, which shows up in the default listing again. An archived customer still holds its taxpayer number, so creating another one with the same number is refused: find it with GET /customers?isArchived=true&taxpayerNumber=… and restore it. Restoring a customer that is not archived has no effect.

Authentication: an API key (`x-api-key`) or an OAuth access token. Send an `Idempotency-Key` to retry this call safely.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Unique customer identifier |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
curl --request POST 'https://api.fiz.co/customers/ID/restore' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.customers.restore('ID');
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.customers.restore("ID")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->customers->restore('ID');
```

### Response `200`

Customer restored successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique customer identifier |
| `taxpayerNumber` | string · can be null | Tax number (NIF) |
| `name` | string · can be null | Customer name |
| `photo` | string · can be null | Photo URL |
| `companyName` | string · can be null | Company name |
| `companyPosition` | string · can be null | Position in the company |
| `email` | string · can be null | Customer email |
| `website` | string · can be null | Website |
| `description` | string · can be null | Description |
| `address` | string · can be null | Address |
| `postalCode` | string · can be null | Postal code |
| `country` | string · can be null | Country code |
| `phone` | string · can be null | Phone |
| `fax` | string · can be null | Fax |
| `mobile` | string · can be null | Mobile phone |
| `city` | string · can be null | City |
| `isArchived` | boolean · can be null | Whether the customer is archived. An archived customer is left out of the default listing and can be restored with POST /customers/{id}/restore. |

### Errors

-   `400` Invalid ID
-   `401` Unauthorized - API key missing or invalid
-   `404` Customer not found
-   `409` A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
-   `422` The idempotency key was already used with a different request body
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Errors

Errors share one shape: `statusCode`, `message`, `code` and `error`, with the request id in the `X-Request-Id` header.

## All resources

-   [Company](https://api.fiz.co/docs/api/company) ([Markdown](https://api.fiz.co/docs/api/company.md))
-   [Customers](https://api.fiz.co/docs/api/customers) ([Markdown](https://api.fiz.co/docs/api/customers.md))
-   [Items](https://api.fiz.co/docs/api/items) ([Markdown](https://api.fiz.co/docs/api/items.md))
-   [Invoices](https://api.fiz.co/docs/api/invoices) ([Markdown](https://api.fiz.co/docs/api/invoices.md))
-   [Recurring invoices](https://api.fiz.co/docs/api/recurring-invoices) ([Markdown](https://api.fiz.co/docs/api/recurring-invoices.md))
-   [Pro formas](https://api.fiz.co/docs/api/pro-formas) ([Markdown](https://api.fiz.co/docs/api/pro-formas.md))
-   [Transport documents](https://api.fiz.co/docs/api/transport-documents) ([Markdown](https://api.fiz.co/docs/api/transport-documents.md))
-   [Series](https://api.fiz.co/docs/api/series) ([Markdown](https://api.fiz.co/docs/api/series.md))
-   [PDF templates](https://api.fiz.co/docs/api/pdf-templates) ([Markdown](https://api.fiz.co/docs/api/pdf-templates.md))
-   [Exports](https://api.fiz.co/docs/api/exports) ([Markdown](https://api.fiz.co/docs/api/exports.md))
-   [Expenses](https://api.fiz.co/docs/api/expenses) ([Markdown](https://api.fiz.co/docs/api/expenses.md))
-   [VAT](https://api.fiz.co/docs/api/vat) ([Markdown](https://api.fiz.co/docs/api/vat.md))
-   [Bank](https://api.fiz.co/docs/api/bank) ([Markdown](https://api.fiz.co/docs/api/bank.md))
