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

# Get Latest Audit

> Latest audit of one type for a brand, or ``null`` when none exists yet.

``brand_audits`` carries ``UNIQUE (brand_id, audit_type, platform)``. The
optional platform therefore participates in the lookup; omitting it reads
the platform-less (including holistic social) lineage rather than choosing
whichever platform happened to be created most recently. Consumers used
to do list-then-filter client-side, which pulls every audit of every type
to answer a one-row question.

"No audit yet" is the COMMON case (most brands have never run a content
audit), so it is a 200 with a ``null`` body, not a 404 — the caller renders
an empty state with a "Run audit" CTA, and reserving 404 for real errors
keeps that distinguishable.

MUST stay declared above ``/{brand_id}/audits/{audit_id}`` — FastAPI
matches in declaration order, and "latest" would otherwise be parsed as a
UUID path param and 422.



## OpenAPI

````yaml /openapi.json get /api/v1/brands/{brand_id}/audits/latest
openapi: 3.1.0
info:
  title: AITasker
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/brands/{brand_id}/audits/latest:
    get:
      tags:
        - Brands
        - Brands
      summary: Get Latest Audit
      description: >-
        Latest audit of one type for a brand, or ``null`` when none exists yet.


        ``brand_audits`` carries ``UNIQUE (brand_id, audit_type, platform)``.
        The

        optional platform therefore participates in the lookup; omitting it
        reads

        the platform-less (including holistic social) lineage rather than
        choosing

        whichever platform happened to be created most recently. Consumers used

        to do list-then-filter client-side, which pulls every audit of every
        type

        to answer a one-row question.


        "No audit yet" is the COMMON case (most brands have never run a content

        audit), so it is a 200 with a ``null`` body, not a 404 — the caller
        renders

        an empty state with a "Run audit" CTA, and reserving 404 for real errors

        keeps that distinguishable.


        MUST stay declared above ``/{brand_id}/audits/{audit_id}`` — FastAPI

        matches in declaration order, and "latest" would otherwise be parsed as
        a

        UUID path param and 422.
      operationId: get_latest_audit_api_v1_brands__brand_id__audits_latest_get
      parameters:
        - name: brand_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Brand Id
        - name: type
          in: query
          required: true
          schema:
            type: string
            description: Audit type, e.g. 'seo' or 'content_marketing'
            title: Type
          description: Audit type, e.g. 'seo' or 'content_marketing'
        - name: platform
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 64
                pattern: ^[A-Za-z0-9][A-Za-z0-9_-]*$
              - type: 'null'
            description: Platform slug for a platform-scoped audit
            title: Platform
          description: Platform slug for a platform-scoped audit
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/BrandAuditResponse'
                  - type: 'null'
                title: >-
                  Response Get Latest Audit Api V1 Brands  Brand Id  Audits
                  Latest Get
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    BrandAuditResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        brand_id:
          type: string
          format: uuid
          title: Brand Id
        audit_type:
          type: string
          title: Audit Type
        platform:
          anyOf:
            - type: string
            - type: 'null'
          title: Platform
        status:
          type: string
          title: Status
        overall_score:
          anyOf:
            - type: number
            - type: 'null'
          title: Overall Score
        summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary
        results:
          additionalProperties: true
          type: object
          title: Results
        recommendations:
          items: {}
          type: array
          title: Recommendations
        output_files:
          items: {}
          type: array
          title: Output Files
        cost_usd:
          type: number
          title: Cost Usd
          default: 0
        error_message:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Message
        started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Started At
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - brand_id
        - audit_type
        - status
        - created_at
        - updated_at
      title: BrandAuditResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````