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

# Services Report

> Generate a services report and send it as an Excel email attachment.

Generate a report of the services in your broker account. The endpoint sends the report to the specified email addresses.

Spaces in the broker name become underscores. The attachment contains these columns:

| Column              | Source                                           |
| ------------------- | ------------------------------------------------ |
| `Service ID`        | Service number                                   |
| `Registration Date` | Service creation date, formatted as `MM/DD/YYYY` |
| `Client Name`       | Customer name                                    |
| `Client Email`      | Customer email address                           |
| `Plan`              | Service plan                                     |
| `Status`            | Service status                                   |

## Errors

Error responses use `success: false` and an `error` object.

| HTTP status | Error code                 | Message or cause                                                                                                                                      |
| ----------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400`       | `invalid_request`          | The body is not valid JSON. The message is `Invalid JSON in request body`.                                                                            |
| `400`       | `missing_parameter`        | `recipients` is omitted or is `null`. The response lists `recipients` in `required_fields`.                                                           |
| `400`       | `invalid_parameter`        | `recipients` is not an array, contains a non-string or invalid address, or has no valid nonempty address. The response includes `max_recipients: 10`. |
| `400`       | `too_many_recipients`      | The normalized list has more than 10 unique recipients. The response includes `max_recipients: 10`.                                                   |
| `400`       | `invalid_parameter`        | `status_filter` is not an accepted value. The response lists the accepted values.                                                                     |
| `400`       | `no_data`                  | No service matches the filter.                                                                                                                        |
| `401`       | `authentication_failed`    | The Bearer token is missing, invalid, inactive, or expired.                                                                                           |
| `403`       | `insufficient_permissions` | The request IP is not allowed, or the key does not have `reports:generate` or `admin:full`.                                                           |
| `429`       | `rate_limit_exceeded`      | The key reached its rate limit. Use the `Retry-After` response header.                                                                                |
| `500`       | `server_error`             | The API could not read the service data or could not complete report generation.                                                                      |


## OpenAPI

````yaml api/openapi.yaml POST /v1/reports/services
openapi: 3.1.0
info:
  title: Broker API
  version: 1.0.0
  description: API for broker-scoped service, request, and report operations.
servers:
  - url: https://brokers.newyorkcityservers.com/api
    description: Broker Panel API
security:
  - bearerAuth: []
tags:
  - name: Authentication
  - name: Services
  - name: Requests
  - name: Reports
paths:
  /v1/reports/services:
    post:
      tags:
        - Reports
      summary: Services Report
      description: >-
        Generates a filtered services report and emails it to normalized
        recipients. Requires `reports:generate` or `admin:full`.
      operationId: sendServicesReport
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServicesReportRequest'
            example:
              recipients:
                - admin@example.com
                - manager@example.com
              status_filter: active
      responses:
        '200':
          description: Report send attempts completed.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    required:
                      - data
                    properties:
                      data:
                        $ref: '#/components/schemas/ServicesReportResult'
              example:
                success: true
                data:
                  report_type: services
                  total_services: 145
                  recipients_sent: 2
                  recipients_failed: 0
                  filters:
                    status: active
                  generated_at: '2026-06-21T15:00:00.000Z'
        '400':
          $ref: '#/components/responses/ReportBadRequest'
        '401':
          $ref: '#/components/responses/AuthenticationError'
        '403':
          $ref: '#/components/responses/PermissionError'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    ServicesReportRequest:
      type: object
      required:
        - recipients
      properties:
        recipients:
          $ref: '#/components/schemas/ReportRecipients'
        status_filter:
          description: An omitted, null, or empty value applies the all filter.
          oneOf:
            - type: string
              enum:
                - all
                - active
                - pending
                - suspended
                - cancelled
                - ''
            - type: 'null'
          default: all
    SuccessEnvelope:
      type: object
      required:
        - success
      properties:
        success:
          type: boolean
          const: true
        message:
          type: string
        pagination:
          $ref: '#/components/schemas/Pagination'
    ServicesReportResult:
      type: object
      required:
        - report_type
        - total_services
        - recipients_sent
        - recipients_failed
        - filters
        - generated_at
      properties:
        report_type:
          type: string
          const: services
        total_services:
          type: integer
          minimum: 0
        recipients_sent:
          type: integer
          minimum: 0
        recipients_failed:
          type: integer
          minimum: 0
        filters:
          type: object
          required:
            - status
          properties:
            status:
              type: string
              enum:
                - all
                - active
                - pending
                - suspended
                - cancelled
        generated_at:
          type: string
          format: date-time
    ReportRecipients:
      type: array
      minItems: 1
      items:
        type: string
      description: >-
        Items are trimmed and lowercased; empty strings are ignored and
        duplicates are removed. Every remaining value must be an email address,
        and at most 10 unique nonempty recipients may remain.
    Pagination:
      type: object
      required:
        - page
        - perPage
        - total
        - totalPages
      properties:
        page:
          type: integer
          minimum: 1
        perPage:
          type: integer
          minimum: 1
          maximum: 100
        total:
          type: integer
          minimum: 0
        totalPages:
          type: integer
          minimum: 0
    ErrorResponse:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          const: false
        error:
          $ref: '#/components/schemas/Error'
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
        details:
          type: object
          additionalProperties: true
  responses:
    ReportBadRequest:
      description: >-
        Codes `invalid_request`, `missing_parameter`, `invalid_parameter`,
        `too_many_recipients`, or `no_data`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingRecipients:
              value:
                success: false
                error:
                  code: missing_parameter
                  message: Missing or invalid recipients array
                  details:
                    required_fields:
                      - recipients
            tooManyRecipients:
              value:
                success: false
                error:
                  code: too_many_recipients
                  message: Report emails can include at most 10 recipients.
                  details:
                    max_recipients: 10
            noData:
              value:
                success: false
                error:
                  code: no_data
                  message: No services found matching the specified filters
    AuthenticationError:
      description: >-
        Code `authentication_failed` for a missing, malformed, invalid,
        inactive, or expired API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: authentication_failed
              message: Invalid API key
    PermissionError:
      description: >-
        Code `insufficient_permissions` when the request IP is not whitelisted
        or a required scope is missing.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: insufficient_permissions
              message: IP address not whitelisted
    RateLimitError:
      description: Code `rate_limit_exceeded` when the API key exceeds its rate limit.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
            minimum: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: rate_limit_exceeded
              message: Rate limit exceeded
    ServerError:
      description: >-
        Code `server_error` when authentication or internal processing cannot
        complete.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: server_error
              message: Internal server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: >-
        Send the API key in the Authorization bearer header. Production keys
        begin with `sk_live_`.

````