> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alvys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search customers

> Search Alvys customers with paginated POST filters — name, status, billing city and state, credit terms, sales rep, and default rate agreements.

The endpoint for searching customers allows you to retrieve a paginated list of customer records based on specific filters and criteria. It requires specifying mandatory parameters like page number, page size, and statuses in the request body, ensuring precise and efficient querying. Optional filters such as date range provide additional control over the search results. For more information on how versioning works and how to include it in your requests, please refer to the [Versioning](/docs/versioning) page.

### Request Body Parameters

The following parameters are available in the request body:

| Parameter              | Type               | Required | Description                                              |
| ---------------------- | ------------------ | -------- | -------------------------------------------------------- |
| Page                   | Integer            | Yes      | The page number for pagination.                          |
| PageSize               | Integer            | Yes      | The number of records to retrieve per page.              |
| Statuses               | Array              | Yes      | List of customer statuses to filter by (e.g., "Active"). |
| CreatedDateRange       | Object             | No       | The date range for filtering created customers.          |
| CreatedDateRange.Start | String (Date-Time) | No       | The start date for filtering.                            |
| CreatedDateRange.End   | String (Date-Time) | No       | The end date for filtering.                              |

***

#### Example CURL Request

```bash theme={null}
curl --location 'https://integrations.alvys.com/api/p/v1/customers/search' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
  "Page": 0,
  "PageSize": 100,
  "Statuses": ["Active"],
  "CreatedDateRange": {
    "Start": "2024-11-08T19:38:34.529Z",
    "End": "2024-11-08T19:38:34.529Z"
  }
}'
```

Replace `YOUR_ACCESS_TOKEN` with your actual Bearer token. Adjust the `page`, `pageSize`, and date range as needed.

### Response Fields

The following fields are returned in the response:

| Field                                   | Type               | Description                                                                                                 |
| --------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------- |
| Page                                    | Integer            | The current page number of the response.                                                                    |
| PageSize                                | Integer            | The number of records returned per page.                                                                    |
| Total                                   | Integer            | The total number of customer records available.                                                             |
| Id                                      | String             | The unique identifier of the customer.                                                                      |
| Name                                    | String             | The name of the customer.                                                                                   |
| CompanyNumber                           | String             | The company number of the customer. A customer-provided reference or registration number for their company. |
| Type                                    | String             | The type of customer (e.g., "Customer" or "Broker/3PL").                                                    |
| Status                                  | String             | The status of the customer. Either "Active" or "Inactive".                                                  |
| BillingAddress                          | Object             | The billing address of the customer.                                                                        |
| BillingAddress.Street                   | String             | The street address of the billing location.                                                                 |
| BillingAddress.City                     | String             | The city of the billing address.                                                                            |
| BillingAddress.State                    | String             | The state of the billing address.                                                                           |
| BillingAddress.ZipCode                  | String             | The postal code of the billing address.                                                                     |
| Email                                   | Array              | A list of email addresses associated with the customer.                                                     |
| Phone                                   | Array              | A list of phone numbers associated with the customer.                                                       |
| Fax                                     | String             | The fax number of the customer.                                                                             |
| DateCreated                             | String (Date-Time) | The date and time when the customer was created.                                                            |
| InvoicingInformation                    | Object             | The invoicing information for the customer.                                                                 |
| InvoicingInformation.Address            | Object             | The address used for invoicing.                                                                             |
| InvoicingInformation.Address.Street     | String             | The street address for invoicing.                                                                           |
| InvoicingInformation.Address.City       | String             | The city of the invoicing address.                                                                          |
| InvoicingInformation.Address.State      | String             | The state of the invoicing address.                                                                         |
| InvoicingInformation.Address.ZipCode    | String             | The postal code of the invoicing address.                                                                   |
| InvoicingInformation.EmailAddresses     | Array              | Email addresses used for invoicing.                                                                         |
| InvoicingInformation.PhoneNumber        | String             | The phone number used for invoicing.                                                                        |
| InvoicingInformation.InvoicingName      | String             | The name used for invoicing.                                                                                |
| InvoicingInformation.InvoicingNameAlias | String             | The alias for the invoicing name.                                                                           |
| InvoicingInformation.PaymentType        | String             | The payment type for invoicing.                                                                             |
| InvoicingInformation.PaymentTermsInDays | Integer            | The payment terms, in days.                                                                                 |
| ExternalId                              | String             | The external identifier associated with the customer.                                                       |
| Contacts                                | Array              | A list of contacts associated with the customer.                                                            |
| SalesAgentId                            | String             | The identifier of the assigned sales agent.                                                                 |
| Notes                                   | Array              | A list of notes related to the customer.                                                                    |
| Notes.id                                | String             | The unique identifier of the note.                                                                          |
| Notes.Description                       | String             | The description of the note.                                                                                |
| Notes.NoteType                          | String             | The type of the note.                                                                                       |
| Notes.Time                              | String (Date-Time) | The time the note was created.                                                                              |
| Notes.User                              | String             | The user who created the note.                                                                              |

### Rate Limits

All endpoints are subject to rate limits to ensure stability and performance. For more information, refer to the [Rate Limits](/docs/rate-limits) section.

This page is interactive, allowing you to try a request by completing the fields for the parameters below. As you fill out the parameters, the CURL command on the right side of the page will be automatically updated. Alternatively, you can fork our [Public API Postman Collection](https://app.getpostman.com/run-collection/39138316-54c493c3-15e5-4fd7-a651-6e45b308548f?action=collection%2Ffork\&source=rip_markdown\&collection-url=entityId%3D39138316-54c493c3-15e5-4fd7-a651-6e45b308548f%26entityType%3Dcollection%26workspaceId%3Dc0255544-5964-4c52-9d24-05b30a9b021c) directly. Make sure to authorize yourself before trying a request.


## OpenAPI

````yaml POST /api/p/v{version}/customers/search
openapi: 3.0.1
info:
  title: Alvys
  description: >-
    Alvys provides a robust set of REST APIs to allow you to integrate Alvys
    into virtually any platform. These APIs cover most of Alvys' major product
    areas with additional endpoints being added regularly based on customer
    requests.
  contact:
    name: Alvys Support
    url: https://www.alvys.com/resources/contact/
  version: v1
servers:
  - url: https://integrations.alvys.com
    description: Public API Server
  - url: https://api.alvys.com/
    description: Public API Server
security:
  - Public: []
tags:
  - name: Authentication
    description: Obtain an OAuth 2.0 access token for the Alvys Public API.
  - name: Carrier Settlement Statements
    description: >-
      Search carrier settlement statements and retrieve a single statement by
      number.
  - name: Carriers
    description: Read carrier records, search carriers, and manage carrier documents.
  - name: Customers
    description: Create, read, update, delete, and search customer records.
  - name: Deductions
    description: >-
      Create one-time deductions and search or delete existing deduction
      records.
  - name: DispatchPreferences
    description: Dispatch preferences endpoints for reading dispatch rules and preferences.
  - name: Driver Settlement Statements
    description: >-
      Search driver settlement statements and retrieve a single statement by
      number.
  - name: Drivers
    description: >-
      Read driver records, search drivers and driver events, and manage driver
      documents.
  - name: Fuel
    description: Read and search fuel transactions.
  - name: Invoices
    description: >-
      Read invoices, create carrier invoices, and record carrier and customer
      payments.
  - name: Loads
    description: Read, update, search loads, and manage load documents and notes.
  - name: Locations
    description: Read and search company location details.
  - name: Maintenance
    description: Read and search maintenance records.
  - name: Tenders
    description: Create, accept, reject, cancel, update, and search inbound EDI tenders.
  - name: Tolls
    description: Read and search toll transactions.
  - name: Trailers
    description: Read trailers, search trailer events, and manage trailer documents.
  - name: Trips
    description: >-
      Read, search trips, manage trip documents, and record stop appointments,
      arrivals, and departures.
  - name: Trucks
    description: Read trucks, search truck events, and manage truck documents.
  - name: Users
    description: List and search users.
  - name: Visibility
    description: >-
      Read inbound and outbound visibility history and search outbound
      visibility errors.
  - name: Webhooks
    description: >-
      Create, read, update, delete, enable, disable, verify, test, and rotate
      secrets for webhook subscriptions; read event types, delivery logs, and
      health metrics.
paths:
  /api/p/v{version}/customers/search:
    post:
      tags:
        - Customers
      summary: Search customers
      parameters:
        - name: version
          in: path
          description: API version (e.g., 1.0)
          required: true
          schema:
            type: string
            default: '1.0'
            example: '1.0'
      requestBody:
        content:
          application/json-patch+json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Loads.CustomerSearchRequest
          application/json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Loads.CustomerSearchRequest
          text/json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Loads.CustomerSearchRequest
          application/*+json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Loads.CustomerSearchRequest
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Alvys.Helpers.PagedResponse1Alvys.Models.Customers.CustomerResponse
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Microsoft.AspNetCore.Mvc.ValidationProblemDetails
        '401':
          description: Unauthorized
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
        '429':
          description: Too Many Requests
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
      security:
        - Public: []
components:
  schemas:
    Alvys.Models.Loads.CustomerSearchRequest:
      required:
        - Page
        - PageSize
        - Statuses
      type: object
      properties:
        Page:
          type: integer
          format: int32
        PageSize:
          type: integer
          format: int32
        Statuses:
          type: array
          items:
            type: string
        CreatedDateRange:
          allOf:
            - $ref: '#/components/schemas/Alvys.Models.Period'
          nullable: true
      additionalProperties: false
    Alvys.Helpers.PagedResponse1Alvys.Models.Customers.CustomerResponse:
      required:
        - Items
        - Page
        - PageSize
        - Total
      type: object
      properties:
        Page:
          type: integer
          format: int32
        PageSize:
          type: integer
          format: int32
        Facets:
          type: object
          additionalProperties:
            type: array
            items:
              $ref: '#/components/schemas/Alvys.Helpers.ResultSetFacetItem'
          nullable: true
        Total:
          type: integer
          format: int64
        Items:
          type: array
          items:
            $ref: '#/components/schemas/Alvys.Models.Customers.CustomerResponse'
      additionalProperties: false
    Microsoft.AspNetCore.Mvc.ValidationProblemDetails:
      required:
        - Errors
      type: object
      properties:
        Errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
        Type:
          type: string
          nullable: true
        Title:
          type: string
          nullable: true
        Status:
          type: integer
          format: int32
          nullable: true
        Detail:
          type: string
          nullable: true
        Instance:
          type: string
          nullable: true
      additionalProperties: {}
    Microsoft.AspNetCore.Mvc.ProblemDetails:
      type: object
      properties:
        Type:
          type: string
          nullable: true
        Title:
          type: string
          nullable: true
        Status:
          type: integer
          format: int32
          nullable: true
        Detail:
          type: string
          nullable: true
        Instance:
          type: string
          nullable: true
      additionalProperties: {}
    Alvys.Models.Period:
      required:
        - Start
      type: object
      properties:
        Start:
          type: string
          format: date-time
        End:
          type: string
          format: date-time
          nullable: true
      additionalProperties: false
    Alvys.Helpers.ResultSetFacetItem:
      required:
        - Count
        - Value
      type: object
      properties:
        Value:
          type: string
        Count:
          type: integer
          format: int64
      additionalProperties: false
    Alvys.Models.Customers.CustomerResponse:
      required:
        - CompanyNumber
        - Contacts
        - Email
        - Id
        - Name
        - Notes
        - Phone
        - Status
        - Type
      type: object
      properties:
        Id:
          type: string
        Name:
          type: string
        CompanyNumber:
          type: string
        Type:
          type: string
        Status:
          type: string
        BillingAddress:
          allOf:
            - $ref: '#/components/schemas/Alvys.Features.Locations.ShortAddress'
          nullable: true
        Email:
          type: array
          items:
            type: string
        Phone:
          type: array
          items:
            type: string
        Fax:
          type: string
          nullable: true
        DateCreated:
          type: string
          format: date-time
          nullable: true
        InvoicingInformation:
          allOf:
            - $ref: >-
                #/components/schemas/Alvys.Models.Customers.InvoicingInformationResponse
          nullable: true
        ExternalId:
          type: string
          nullable: true
        Contacts:
          type: array
          items:
            $ref: '#/components/schemas/Alvys.Models.Customers.ContactResponse'
        SalesAgentId:
          type: string
          nullable: true
        Notes:
          type: array
          items:
            $ref: '#/components/schemas/Alvys.Models.Notes.NoteDto'
      additionalProperties: false
    Alvys.Features.Locations.ShortAddress:
      required:
        - City
        - State
        - Street
        - ZipCode
      type: object
      properties:
        Street:
          type: string
        City:
          type: string
        State:
          type: string
        ZipCode:
          type: string
      additionalProperties: false
    Alvys.Models.Customers.InvoicingInformationResponse:
      required:
        - EmailAddresses
      type: object
      properties:
        Address:
          allOf:
            - $ref: '#/components/schemas/Alvys.Features.Locations.ShortAddress'
          nullable: true
        EmailAddresses:
          type: array
          items:
            type: string
        PhoneNumber:
          type: string
          nullable: true
        InvoicingName:
          type: string
          nullable: true
        InvoicingNameAlias:
          type: string
          nullable: true
        PaymentType:
          type: string
          nullable: true
        PaymentTermsInDays:
          type: integer
          format: int32
          nullable: true
      additionalProperties: false
    Alvys.Models.Customers.ContactResponse:
      required:
        - Id
        - PrimaryContact
      type: object
      properties:
        Id:
          type: string
        Name:
          type: string
          nullable: true
        Email:
          type: string
          nullable: true
        Phone:
          type: string
          nullable: true
        Mobile:
          type: string
          nullable: true
        Extension:
          type: string
          nullable: true
        Title:
          type: string
          nullable: true
        PrimaryContact:
          type: boolean
      additionalProperties: false
    Alvys.Models.Notes.NoteDto:
      required:
        - Description
        - id
        - NoteType
        - User
      type: object
      properties:
        id:
          type: string
        Description:
          type: string
        NoteType:
          type: string
        Time:
          type: string
          format: date-time
          nullable: true
        User:
          type: string
        UserId:
          type: string
          nullable: true
      additionalProperties: false
  securitySchemes:
    Public:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        OAuth 2.0 client-credentials access token. Obtain one from
        https://auth.alvys.com/oauth/token (grant_type=client_credentials,
        audience=https://api.alvys.com/public/), then paste it here. The
        playground sends it as `Authorization: Bearer <token>`.

````