<!-- Generated by scripts/build-docs.js. Edit docs/swagger.yaml or docs/guides/, then run `npm run docs:build`. -->

# List custom fields

`GET https://marketplace-api.sequifi.com/v1/custom-fields`

Module: Custom Fields · operationId: `listCustomFields` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/list-custom-fields

Lists your company's custom field definitions for one `type`: `sales`, `payroll`, `employee`, `employee_admin` or `onboarding`. Use `type=sales` to get the field `id`s to send in `custom_field_values` on `POST /v1/sales`. Answer options for select and multi-select fields are not returned.

**What happens:**

- Read-only: definitions, not values. Values are written through the endpoint that owns the record: `POST /v1/sales` (`custom_field_values`, keyed by field `id` or exact name), `POST /v1/payroll` (`custom_fields`, by exact `field_name`) and `POST /v1/onboarding` (`custom_fields`, by exact `field_name`).
- `sales`: active fields only, ordered by `sort_order` then name. Each field has `can_archive`, plus `usage_details` when commission, override or upfront settings use it. Archived fields are hidden here, but `POST /v1/sales` still accepts values for them and `GET /v1/sales` still returns them.
- `payroll`: every field, by `id`.
- `employee`: fields that are not deleted, by `id`. `attribute_option` is the list of options.
- `employee_admin`: admin-only fields that are not deleted, by `id`. Use these ids in `employee_admin_only_fields` on `POST /v1/users`.
- `onboarding`: fields that are not deleted, by `id`, in a different shape: `data.onboard[]` and `data.custom_lead_form_settings`, with no paging fields.

**Filtering and paging:**

- `type` is required and case-insensitive. Other query parameters are ignored, not rejected.
- `page` (default 1) and `per_page` (default 20, maximum 500) must be whole numbers in range, else `400`. The `onboarding` type checks them and then returns every field.
- `last_page` is at least `1`, even when there are no fields.

**Formats:**

- Sales field `type` is `text`, `number`, `date` or `multi_select`. A single-select field is a `text` field with configured options, and this endpoint cannot tell it apart from free text.
- `created_at` and `updated_at` are UTC timestamps.

**Errors:**

- `400 Bad Request: ?type= is required. Valid values: sales, payroll, onboarding, employee, employee_admin`.
- `400 Bad Request: invalid type "<type>". Valid values: sales, payroll, onboarding, employee, employee_admin`.
- `400 Bad Request: page must be a positive integer` or `Bad Request: per_page must be a positive integer between 1 and 500`.
- `401`: missing, invalid or expired token. The body is `{"message": "Unauthorized"}`.
- `500 Database Connection Error`, `Database Query Error` or `Internal Server Error`: retry later. `data.details` is a technical message; do not parse it.

**Common mistakes:**

- Keying `custom_field_values` on `POST /v1/sales` by a name with different capitals or spaces. Names must match exactly; send the numeric `id`.
- Sending values for fields with `is_calculated: true`. Sequifi calculates them.

**Related:**

- `POST /v1/sales`: write sales custom field values.
- `GET /v1/sales`: read values back, keyed by field name.

## Query parameters

- `type` (string, **required**): Which fields to list. Case-insensitive. One of: `sales`, `payroll`, `onboarding`, `employee`, `employee_admin`. Example: `sales`.
- `page` (integer): Page number, starting at 1. Must be a whole number, else `400`. Default: `1`. Minimum: 1.
- `per_page` (integer): Fields per page. Default 20, maximum 500. Must be a whole number in range, else `400`. Default: `20`. Minimum: 1. Maximum: 500.

## Example request

```bash
curl -X GET "https://marketplace-api.sequifi.com/v1/custom-fields" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN"
```

## Responses

### 200: Field definitions for the requested type.

- `status` (integer): The HTTP status code, repeated. Example: `200`.
- `message` (string): Short text. Wording varies by endpoint; branch on the HTTP status, not on this text. Example: `success`.
- `data` (object)
  - `type` (string): The type listed. Not returned for `onboarding`.
  - `current_page` (integer): Page returned. Not returned for `onboarding`.
  - `per_page` (integer): Page size used. Not returned for `onboarding`.
  - `total` (integer): Number of fields of this type. Not returned for `onboarding`.
  - `last_page` (integer): Last page number, at least `1`. Not returned for `onboarding`.
  - `custom_fields` (array of object): The fields on this page. The item shape below is for `type=sales`; see the examples for `payroll` and `employee`.
    - `id` (integer): Field id. Use it as the key in `custom_field_values` on `POST /v1/sales`.
    - `name` (string): Field name. `GET /v1/sales` keys values by this name.
    - `type` (string): Value type. `number` takes a number and `date` takes `YYYY-MM-DD`. A single-select field is a `text` field with configured options; the options are not returned. One of: `text`, `number`, `date`, `multi_select`.
    - `field_category` (string): Field category as stored, for example `custom_sales`.
    - `is_calculated` (boolean): `true` when Sequifi calculates the value from a formula. Do not send values for it.
    - `is_available_in_position` (boolean): `true` when the field can be used in position commission settings.
    - `formula` (object, nullable): The formula for a calculated field, else `null`.
    - `visiblecustomer` (boolean): `true` when the field is shown on the customer view.
    - `status` (boolean): Always `true` here (only active fields are listed).
    - `sort_order` (integer): Display order.
    - `created_at` (string (date-time), nullable): When the field was created (UTC).
    - `updated_at` (string (date-time), nullable): When the field was last changed (UTC).
    - `can_archive` (boolean): `false` when commission, override or upfront settings use the field.
    - `usage_details` (object): Present only when the field is in use. Depending on your company's settings it holds `position_commissions` (`count` and `positions`) or `formulas`, `commissions`, `overrides` and `upfronts` (users keyed by id).
  - `onboard` (array of object): Onboarding fields. Returned only for `type=onboarding`.
  - `custom_lead_form_settings` (object): Onboarding form settings. Returned only for `type=onboarding`.

Example (sales_response): type=sales

```json
{
  "status": 200,
  "message": "Custom fields fetched successfully",
  "data": {
    "type": "sales",
    "current_page": 1,
    "per_page": 20,
    "total": 2,
    "last_page": 1,
    "custom_fields": [
      {
        "id": 7,
        "name": "Roof Type",
        "type": "text",
        "field_category": "custom_sales",
        "is_calculated": false,
        "is_available_in_position": false,
        "formula": null,
        "visiblecustomer": false,
        "status": true,
        "sort_order": 1,
        "created_at": "2026-01-05T17:20:00.000Z",
        "updated_at": "2026-03-02T15:45:10.000Z",
        "can_archive": true
      },
      {
        "id": 9,
        "name": "Panel Count",
        "type": "number",
        "field_category": "custom_sales",
        "is_calculated": false,
        "is_available_in_position": true,
        "formula": null,
        "visiblecustomer": true,
        "status": true,
        "sort_order": 2,
        "created_at": "2026-01-05T17:21:00.000Z",
        "updated_at": "2026-03-02T15:45:10.000Z",
        "can_archive": false,
        "usage_details": {
          "position_commissions": {
            "count": 2,
            "positions": [
              {
                "id": 1,
                "name": "Sales Rep"
              },
              {
                "id": 2,
                "name": "Manager"
              }
            ]
          }
        }
      }
    ]
  }
}
```

Example (payroll_response): type=payroll

```json
{
  "status": 200,
  "message": "Custom fields fetched successfully",
  "data": {
    "type": "payroll",
    "current_page": 1,
    "per_page": 20,
    "total": 1,
    "last_page": 1,
    "custom_fields": [
      {
        "id": 10,
        "field_name": "Car Allowance",
        "worked_type": "hourly",
        "payment_type": "addition",
        "status": 1
      }
    ]
  }
}
```

### 400: Missing or invalid `type`, `page` or `per_page`.

Example (missing_type): type missing

```json
{
  "status": 400,
  "message": "Bad Request: ?type= is required. Valid values: sales, payroll, onboarding, employee",
  "data": {}
}
```

### 401: Missing, invalid or expired token. The body has only `message`.

```json
{
  "message": "Unauthorized"
}
```

### 500: Server error. Retry later.

Example (db_connection): Sequifi could not reach your company's data

```json
{
  "status": 500,
  "message": "Database Connection Error",
  "data": {
    "details": "Connection timed out"
  }
}
```
