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

# Test a cron expression

> Returns the next check-in window for the cron expression. An invalid expression, timezone or timestamp still returns 200 with `error` set and no window.

Use it to check a cron expression before you [create a cron process monitor](https://docs.appsignal.com/check-ins/create.md#create-a-process-monitor).

```yaml POST /api/v2/check_ins/test_cron theme={null}
openapi: 3.1.0
info:
  title: AppSignal V2 API
  description: >-
    REST API for metrics, traces, logs, Kubernetes monitoring, and deployment
    tracking.
  license:
    name: ''
  version: 0.1.0
paths:
  /api/v2/check_ins/test_cron:
    post:
      tags:
        - Check-ins
      summary: Test a cron expression
      description: >-
        Returns the next check-in window for the cron expression. An invalid
        expression, timezone or timestamp still returns 200 with `error` set and
        no window.
      operationId: test_cron
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CronQuery'
            example:
              cron: 0 6 * * *
              wait_time_minutes: 5
              timestamp: 1614556800
              timezone: Europe/Amsterdam
        required: true
      responses:
        '200':
          description: The next window, or an error message when the input is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CronQueryResult'
              examples:
                Invalid:
                  summary: Invalid expression
                  value:
                    now: '2021-03-01T00:00:00Z'
                    next_start: null
                    next_end: null
                    error: 'Invalid cron error: Invalid pattern: ...'
                Valid:
                  summary: Valid expression
                  value:
                    now: '2021-03-01T00:00:00Z'
                    next_start: '2021-03-01T05:00:00Z'
                    next_end: '2021-03-01T05:05:00Z'
                    error: null
        '400':
          description: Malformed request, or input the server cannot process.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
        '401':
          description: Missing or invalid authentication token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Route or resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: External query concurrency limit exceeded; retry shortly.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequestsResponse'
        '500':
          description: Unhandled server-side failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearer_auth: []
        - token_query: []
components:
  schemas:
    BadRequestResponse:
      type: object
      description: >-
        Standard body for HTTP 400 Bad Request responses. Branch on the stable
        `error` slug, display `message` as-is, and read per-error structured
        data from `details`.
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Stable, machine-readable slug identifying the specific error case.
        message:
          type: string
          description: Human-readable message. Safe to log or display to end users.
        details:
          description: >-
            Per-error structured payload. Shape varies by
            [`error`](Self::error).
    CronQuery:
      type: object
      description: Request body for testing a cron schedule expression.
      required:
        - cron
        - wait_time_minutes
      properties:
        cron:
          type: string
          description: Cron expression to test (e.g. `"0 * * * *"`).
        wait_time_minutes:
          type: integer
          format: int64
          description: Wait time in minutes for the check-in window.
        timestamp:
          type:
            - integer
            - 'null'
          format: int64
          description: >-
            Unix timestamp in seconds to evaluate against. Defaults to the
            current time.
        timezone:
          type: string
          description: >-
            IANA timezone for cron evaluation (e.g. `"Europe/Amsterdam"`). An
            empty string means UTC.
          default: ''
    CronQueryResult:
      type: object
      description: Result of evaluating a cron schedule expression.
      required:
        - now
        - next_start
        - next_end
        - error
      properties:
        now:
          type: string
          format: date-time
          description: >-
            The time evaluated against: `timestamp`, or the current time when
            omitted or out of range.
        next_start:
          type:
            - string
            - 'null'
          format: date-time
          description: Next scheduled start time; `null` when `error` is set.
        next_end:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Next scheduled end time (start + wait time); `null` when `error` is
            set.
        error:
          type:
            - string
            - 'null'
          description: >-
            Why no window could be computed (invalid expression, timezone or
            timestamp); `null` on success.
    ErrorResponse:
      type: object
      description: Error body returned for 401, 404 and 500 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
    TooManyRequestsResponse:
      type: object
      description: Error body returned for 429 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
        suggestion:
          type:
            - string
            - 'null'
          description: >-
            A cheaper way to write the request's filter. Only the trace list

            endpoints set it, and only for a filter with a known indexed
            rewrite.
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: '`Authorization: Bearer <token>`'
    token_query:
      type: apiKey
      in: query
      name: token
      description: >-
        Alternative to the Authorization header: pass the token as a
        `?token=<token>` query parameter.
```


## API Specification

The full API specification for this endpoint is available in the [documentation index](https://docs.appsignal.com/llms.txt).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.