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

# Create connection

> Credentials per provider (all are verified with one cheap read before anything is stored; they are encrypted
with AES-256-GCM and never returned):
- `asc`: `{ issuer_id, key_id, private_key, vendor_number? }` from App Store Connect → Users and Access →
  Integrations → App Store Connect API (role App Manager; Sales too for downloads/proceeds sync with
  `vendor_number` from Payments and Financial Reports). `apps` defaults to every app the key can see.
- `play_console`: `{ service_account, reports_bucket? }` = the Google Cloud service account JSON key, invited in
  Play Console → Users and permissions with View app information, Reply to reviews and Edit store listing.
  `apps` (package names) is required. `reports_bucket` (pubsite_prod_…) enables install stats.
- `apple_ads`: `{ client_id, team_id, key_id, private_key, ad_account_id? }` from Apple Ads → Account Settings →
  API for an API user with the API Account Manager role (Apple Ads Platform API; `ad_account_id` is needed when
  the user can access several ad accounts, the error lists them).
Each linked app uses one of the plan's connected apps (`limits.connections`; Free 1, read-only). The default
mode is `actions` (`read_only` on Free).




## OpenAPI

````yaml openapi.json POST /connections
openapi: 3.1.0
info:
  title: AppGoat API
  version: 1.0.0
  summary: App Store + Google Play data for agents and apps.
  description: >
    Every app and developer in both stores, daily top charts, reviews, change
    feeds, metric history and keyword

    (search-rank) intelligence.


    **Conventions**

    - `{app}` accepts anything that identifies an app: an App Store id
    (`284882215`, `id284882215`), a Play
      package (`com.spotify.music`), an Apple bundle id (`com.spotify.client`), a store URL, `apple:<id>` /
      `play:<id>`, or a name (`spotify` → best match, with a warning in `meta.warnings`). Add `store=apple|play`
      to disambiguate. `data.linked` is the same app in the other store when we know it.
    - Freshness is automatic: app-scoped reads refresh data older than `max_age`
    seconds from the store first
      (1 credit per country fetched, capped at 10). `wait=true` (default) blocks up to ~25 s; on timeout, or with
      `wait=false`, you get the cached data with `meta.freshness.refreshing: true` and a `job_id` to poll at
      `GET /v1/jobs/{id}` (free).
    - `country` defaults to `us`; pass a comma list (paid plans) or `all`
    (Studio).

    - `include=` adds sections, `fields=` keeps only the listed top-level
    fields, lists page with `cursor`
      (pass `meta.next_cursor` back unchanged).
    - Every success is `{ data, meta }`; `meta.credits_used` is what the call
    cost and `meta.credits_remaining`
      what is left. Errors are `{ error: { code, message, hint, docs } }`: read `hint`, it says what to do next.
    - `x-credits` on each operation documents its price.

    - Watches turn store changes into events: `POST /v1/watches`, then poll `GET
    /v1/events` or add a webhook
      (`POST /v1/webhooks`). Watches, events and webhooks are free; only the plan's watched-app and keyword-slot
      limits apply. `/v1/tracked-keywords` is deprecated: use keyword watches.
  contact:
    email: support@appgoat.ai
    url: https://appgoat.ai
servers:
  - url: https://api.appgoat.ai/v1
security:
  - apiKey: []
tags:
  - name: Apps
  - name: Search & charts
  - name: Keywords
  - name: Developers
  - name: Audits
  - name: Watches & events
    description: >-
      Watch apps, competitors and keywords; significant changes become events
      (feed, webhooks, Slack, GitHub, daily email digest).
  - name: Webhooks
  - name: Connections
  - name: Actions
  - name: Jobs
  - name: Account
paths:
  /connections:
    post:
      tags:
        - Connections
      summary: >-
        Connect an App Store Connect, Play Console or Apple Ads account
        (credentials are verified, then stored encrypted).
      description: >
        Credentials per provider (all are verified with one cheap read before
        anything is stored; they are encrypted

        with AES-256-GCM and never returned):

        - `asc`: `{ issuer_id, key_id, private_key, vendor_number? }` from App
        Store Connect → Users and Access →
          Integrations → App Store Connect API (role App Manager; Sales too for downloads/proceeds sync with
          `vendor_number` from Payments and Financial Reports). `apps` defaults to every app the key can see.
        - `play_console`: `{ service_account, reports_bucket? }` = the Google
        Cloud service account JSON key, invited in
          Play Console → Users and permissions with View app information, Reply to reviews and Edit store listing.
          `apps` (package names) is required. `reports_bucket` (pubsite_prod_…) enables install stats.
        - `apple_ads`: `{ client_id, team_id, key_id, private_key,
        ad_account_id? }` from Apple Ads → Account Settings →
          API for an API user with the API Account Manager role (Apple Ads Platform API; `ad_account_id` is needed when
          the user can access several ad accounts, the error lists them).
        Each linked app uses one of the plan's connected apps
        (`limits.connections`; Free 1, read-only). The default

        mode is `actions` (`read_only` on Free).
      operationId: createConnection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - provider
                - credentials
              properties:
                provider:
                  $ref: '#/components/schemas/Provider'
                label:
                  type: string
                  description: 'Your name for it (default: provider + key / account).'
                mode:
                  type: string
                  enum:
                    - actions
                    - read_only
                credentials:
                  type: object
                  additionalProperties: true
                  description: See the description for the fields per provider.
                apps:
                  type: array
                  items:
                    type: string
                  description: >-
                    Apps to link: App Store ids / bundle ids (asc, apple_ads) or
                    package names (play_console, required).
            example:
              provider: asc
              label: My ASC key
              credentials:
                issuer_id: 57246542-96fe-1a63-e053-0824d011072a
                key_id: 2X9R4HXF34
                private_key: |-
                  -----BEGIN PRIVATE KEY-----
                  …
                  -----END PRIVATE KEY-----
              apps:
                - '1234567890'
      responses:
        '201':
          description: Connected and verified.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Envelope'
                  - properties:
                      data:
                        $ref: '#/components/schemas/Connection'
        '400':
          $ref: '#/components/responses/InvalidParam'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '422':
          $ref: '#/components/responses/InvalidCredentials'
        '502':
          $ref: '#/components/responses/ProviderError'
components:
  schemas:
    Provider:
      type: string
      enum:
        - asc
        - play_console
        - apple_ads
      description: >-
        asc = App Store Connect, play_console = Google Play Console, apple_ads =
        Apple Ads (Search Ads).
    Envelope:
      type: object
      required:
        - data
        - meta
      properties:
        data: {}
        meta:
          $ref: '#/components/schemas/Meta'
    Connection:
      type: object
      properties:
        id:
          type: string
          example: con_x8Hq2mXc0aLpQwRtYb
        provider:
          $ref: '#/components/schemas/Provider'
        label:
          type: string
        mode:
          type: string
          enum:
            - actions
            - read_only
        status:
          type: string
          enum:
            - active
            - invalid
            - deleted
        account:
          type: object
          additionalProperties: true
          description: >-
            Non-secret identifiers (issuer_id, key_id, client_email,
            ad_account_id, ad_account_name, currency, …).
        apps:
          type: array
          items:
            $ref: '#/components/schemas/LinkedApp'
        last_verified_at:
          type:
            - string
            - 'null'
          format: date-time
        last_error:
          type:
            - string
            - 'null'
        last_synced_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Last downloads / proceeds sync (ASC with vendor_number
          Play with reports_bucket).: null
        created_at:
          type: string
          format: date-time
        available_apps:
          type: array
          items:
            $ref: '#/components/schemas/LinkedApp'
          description: Only on verify.
    Meta:
      type: object
      properties:
        credits_used:
          type: integer
        credits_remaining:
          type: integer
          description: Added by the gateway.
        request_id:
          type: string
          description: Added by the gateway.
        freshness:
          $ref: '#/components/schemas/Freshness'
        next_cursor:
          type:
            - string
            - 'null'
        store:
          $ref: '#/components/schemas/Store'
        warnings:
          type: array
          items:
            type: string
          description: Things to know (e.g. "resolved by name"); safe to show to the user.
    LinkedApp:
      type: object
      properties:
        store:
          $ref: '#/components/schemas/Store'
        app_id:
          type: string
        external_id:
          type:
            - string
            - 'null'
        title:
          type:
            - string
            - 'null'
        bundle_id:
          type:
            - string
            - 'null'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              enum:
                - invalid_param
                - invalid_credentials
                - unauthorized
                - forbidden
                - insufficient_credits
                - plan_limit
                - free_audit_used
                - not_found
                - app_not_found
                - developer_not_found
                - job_not_found
                - conflict
                - not_ready
                - rate_limited
                - provider_error
                - internal_error
                - not_configured
            message:
              type: string
            hint:
              type: string
              description: What to do next.
            docs:
              type: string
              format: uri
            param:
              type: string
    Freshness:
      type: object
      properties:
        fetched_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the oldest requested country was last fetched from the store.
        age_seconds:
          type:
            - integer
            - 'null'
        stale:
          type: boolean
          description: Older than max_age (or missing).
        refreshing:
          type: boolean
          description: A store fetch is still running; poll job_id.
        job_id:
          type:
            - string
            - 'null'
    Store:
      type: string
      enum:
        - apple
        - play
  responses:
    InvalidParam:
      description: A parameter is missing or invalid (`error.param` names it).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_param
              message: limit must be ≤ 100
              hint: Fix the parameter and retry.
              docs: https://appgoat.ai/docs/errors#invalid_param
              param: limit
    PaymentRequired:
      description: >-
        `insufficient_credits` (the call costs more than you have left; nothing
        was done) or `plan_limit` (a feature of a higher plan).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InvalidCredentials:
      description: >-
        The provider rejected the credentials, or a field is missing; `hint`
        says where to find / fix it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ProviderError:
      description: >-
        App Store Connect / Google Play / Apple Ads answered with an error
        (message passed through).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Create a key at https://dash.appgoat.ai.

````

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