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

# List deals

> Returns all deals visible to the current user. Non-admins see only their
own deals. Admins see all deals and can optionally filter by council.
Deals are sorted by last-modified date descending.

**Nonce:** `sagescreen_frontend_nonce`
**Capability:** `ss_sales` or `ss_sales_admin` or `ss_admin_all`




## OpenAPI

````yaml /openapi/private/specs/wp/deal-internal.yml post /wp-admin/admin-ajax.php?action=sagescreen_get_deals
openapi: 3.1.0
info:
  title: SageScreen — Deal Module
  description: >
    Enterprise deal lifecycle management. Deals represent sales proposals that

    flow through a multi-stage approval and payment pipeline before provisioning

    a council.


    **CPT:** `ss_deal`

    **Custom statuses:** `draft`, `ss_pending_approval`, `ss_approved`,

    `ss_customer_sent`, `ss_customer_approved`, `ss_customer_rejected`,

    `ss_invoiced`, `ss_paid`, `ss_closed`, `ss_lost`


    **Business rule:** Only Enterprise (E-SKU) products go through the
    deal/sales

    process. Packs and subscriptions are not sold via deals. Trials are
    Stripe-only.
  version: 1.0.0
servers:
  - url: https://{domain}/wp-json/sagescreen/v1
    description: WordPress REST API
    variables:
      domain:
        default: api.sagescreen.app
security: []
tags:
  - name: Deal REST
    description: REST API endpoints authenticated via X-API-Key
  - name: Deal AJAX
    description: AJAX endpoints authenticated via WordPress nonce + capability check
paths:
  /wp-admin/admin-ajax.php?action=sagescreen_get_deals:
    post:
      tags:
        - Deal AJAX
      summary: List deals
      description: |
        Returns all deals visible to the current user. Non-admins see only their
        own deals. Admins see all deals and can optionally filter by council.
        Deals are sorted by last-modified date descending.

        **Nonce:** `sagescreen_frontend_nonce`
        **Capability:** `ss_sales` or `ss_sales_admin` or `ss_admin_all`
      operationId: ajaxGetDeals
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - nonce
                - action
              properties:
                nonce:
                  type: string
                  examples:
                    - abc123def456
                action:
                  type: string
                  const: sagescreen_get_deals
                council_id:
                  type: integer
                  description: Optional council post ID filter (admin only)
                  examples:
                    - 312
      responses:
        '200':
          description: Deals list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AjaxGetDealsResponse'
              example:
                success: true
                data:
                  deals:
                    - id: 1042
                      customer_name: Greenville City Council
                      contact_name: Bob Johnson
                      status: ss_approved
                      date_created: Feb 15, 2026 9:00 AM
                      date_modified: Feb 19, 2026 2:30 PM
                    - id: 1038
                      customer_name: Riverside County
                      contact_name: ''
                      status: draft
                      date_created: Feb 10, 2026 11:15 AM
                      date_modified: Feb 10, 2026 11:15 AM
                  is_admin: false
        '403':
          $ref: '#/components/responses/AjaxForbidden'
      security:
        - wpAjaxNonce: []
components:
  schemas:
    AjaxGetDealsResponse:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
          properties:
            deals:
              type: array
              items:
                $ref: '#/components/schemas/DealListItem'
            is_admin:
              type: boolean
              description: Whether the current user has admin access
              examples:
                - false
    DealListItem:
      type: object
      properties:
        id:
          type: integer
          examples:
            - 1042
        customer_name:
          type: string
          examples:
            - Greenville City Council
        contact_name:
          type: string
          examples:
            - Bob Johnson
        status:
          $ref: '#/components/schemas/DealStatus'
        date_created:
          type: string
          description: Formatted datetime
          examples:
            - Feb 15, 2026 9:00 AM
        date_modified:
          type: string
          examples:
            - Feb 19, 2026 2:30 PM
        closed_month:
          type: string
          description: YYYY-MM format (present only for paid/closed deals)
          examples:
            - 2026-02
        owner:
          type: string
          description: Display name of deal owner (admin view only)
          examples:
            - Jane Smith
    AjaxErrorResponse:
      type: object
      description: WordPress AJAX error envelope (wp_send_json_error)
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          const: false
        data:
          oneOf:
            - type: object
              properties:
                message:
                  type: string
                  description: Human-readable error message
                  examples:
                    - Deal not found
                errors:
                  type: array
                  description: Validation error list (submit_deal only)
                  items:
                    type: string
                  examples:
                    - - Customer name is required
                      - Contact email is required
                redirect_edit:
                  type: boolean
                  description: Whether front end should redirect to edit form
                  examples:
                    - true
                edit_url:
                  type: string
                  description: URL to redirect to for fixing validation errors
                  examples:
                    - /admin/sales/calc?deal=1042
            - type: string
              description: Simple error message string
              examples:
                - Deal not found
    DealStatus:
      type: string
      enum:
        - draft
        - ss_pending_approval
        - ss_approved
        - ss_customer_sent
        - ss_customer_approved
        - ss_customer_rejected
        - ss_invoiced
        - ss_paid
        - ss_closed
        - ss_lost
      description: Custom post status for `ss_deal`
  responses:
    AjaxForbidden:
      description: User does not have the required capability
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AjaxErrorResponse'
          example:
            success: false
            data:
              message: You do not have permission to perform this action
  securitySchemes:
    wpAjaxNonce:
      type: apiKey
      in: query
      name: nonce
      description: |
        WordPress AJAX nonce — either `sagescreen_frontend_nonce` or
        `sagescreen_sales_calc` depending on the endpoint (see each endpoint
        description). Sent as a form field in the POST body.

````