openapi: 3.1.0
info:
  title: Inline Partner API
  version: 1.0.0
  description: |
    Token-authenticated REST API for organizations that work with Inline AI.
    Every request needs `Authorization: Bearer <token>`. Tokens are created in the
    Inline dashboard, belong to one organization, and have scopes. Changes within
    v1 are additive: new optional fields, parameters, endpoints, and error codes
    may appear, so clients must ignore unknown response fields.
servers:
  - url: https://partner-api.getinline.tech
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Token
  - name: Reports
paths:
  /v1/ping:
    get:
      tags: [Token]
      operationId: ping
      summary: Check a token and return its organization and scopes
      description: Works with any valid token regardless of scopes.
      x-required-scope: null
      responses:
        '200':
          description: The token is valid.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: '#/components/schemas/PingResult'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
  /v1/reports/revenue:
    get:
      tags: [Reports]
      operationId: getRevenueReport
      summary: Gross and net revenue by day
      description: |
        Your organization's revenue: one row per date and publisher. Gross revenue
        is what ad partners paid; net revenue is your share of it. Refreshed about
        every four hours. Ad partner data for dates two or more UTC days old is
        final (`is_final`), but a revenue share change can still restate net
        revenue for any date, so re-pull the whole range you reconcile. Ranges are
        capped at 92 days.
      x-required-scope: reporting:read
      parameters:
        - $ref: '#/components/parameters/StartDate'
        - $ref: '#/components/parameters/EndDate'
        - $ref: '#/components/parameters/PublisherIdFilter'
        - $ref: '#/components/parameters/ReportLimit'
        - $ref: '#/components/parameters/Cursor'
      responses:
        '200':
          description: A page of revenue rows.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
          content:
            application/json:
              schema:
                type: object
                required: [data, meta]
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/RevenueRow'
                  meta:
                    $ref: '#/components/schemas/RevenueReportMeta'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          $ref: '#/components/responses/Unavailable'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'A token of the form `inl_<live|test>_<key id>_<secret>`.'
  headers:
    X-Request-Id:
      description: Unique id of this request. Quote it when contacting support.
      schema:
        type: string
  parameters:
    StartDate:
      name: start_date
      in: query
      required: true
      description: First UTC date, inclusive (YYYY-MM-DD).
      schema:
        type: string
        format: date
    EndDate:
      name: end_date
      in: query
      required: true
      description: Last UTC date, inclusive (YYYY-MM-DD). Must not be before start_date.
      schema:
        type: string
        format: date
    PublisherIdFilter:
      name: publisher_id
      in: query
      required: false
      description: Only this publisher. 404 if the token cannot reach it.
      schema:
        type: string
        format: uuid
    ReportLimit:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 1000
        default: 1000
    Cursor:
      name: cursor
      in: query
      required: false
      description: The `meta.next_cursor` of the previous page. Opaque; do not construct it.
      schema:
        type: string
  responses:
    InvalidRequest:
      description: The request is malformed or a parameter is invalid.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: The token is missing, malformed, unknown, revoked, or expired.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The token lacks the required scope, or the organization may not perform this action.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The resource does not exist or the token cannot reach it.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: |
        Too many requests. Limits are 300 requests per 5 minutes per token and a
        per-IP limit. Honor `Retry-After` when present, otherwise back off
        exponentially.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unavailable:
      description: The report could not be produced in time. Retry with backoff or narrow the range.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required: [error]
      properties:
        error:
          type: object
          required: [code, message]
          properties:
            code:
              type: string
              description: |
                Machine-readable code. Current values: invalid_request,
                unauthorized, forbidden, not_found, method_not_allowed,
                conflict, rate_limited, internal_error, unavailable. New codes
                may be added; treat an unknown code by its HTTP status.
            message:
              type: string
            request_id:
              type: [string, 'null']
    PingResult:
      type: object
      required: [organization, token]
      properties:
        organization:
          type: object
          required: [id, name]
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
        token:
          type: object
          required: [key_id, scopes, expires_at]
          properties:
            key_id:
              type: string
            scopes:
              type: array
              items:
                $ref: '#/components/schemas/Scope'
            expires_at:
              type: [string, 'null']
              format: date-time
    Scope:
      type: string
      description: reporting:read today. New scopes may be added.
    RevenueReportMeta:
      type: object
      required: [next_cursor, data_through]
      properties:
        next_cursor:
          type: [string, 'null']
        data_through:
          type: [string, 'null']
          format: date
          description: Latest UTC date with loaded revenue, or null if nothing is loaded for the range.
    RevenueRow:
      type: object
      required: [date, publisher_id, primary_domain, gross_revenue, net_revenue, impressions, currency, is_final]
      properties:
        date:
          type: string
          format: date
        publisher_id:
          type: string
          format: uuid
        primary_domain:
          type: string
          description: The publisher's primary domain, lowercase, with no scheme or path. Revenue from the publisher's alternate domains is included in its row.
        gross_revenue:
          type: number
          description: What ad partners paid for your organization's ad traffic on this publisher, before the revenue share, rounded to 6 decimal places.
        net_revenue:
          type: number
          description: Your organization's share of gross_revenue, rounded to 6 decimal places.
        impressions:
          type: integer
          description: Paid ad impressions reported by ad partners.
        currency:
          type: string
          description: ISO 4217 code. Always USD today.
        is_final:
          type: boolean
          description: True when ad partner data for the date is final (two or more UTC days old). A revenue share change can still restate net_revenue.
