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

# Export the tenant's configuration

> Returns the tenant's apps, upstreams, and managed mode users as a
snapshot that `POST /config/sync` accepts. Apps are sorted by
platform and bundle ID, upstreams by host, and each upstream's users
by domain, then username. pgw returns no secret: it leaves out
`apns_key_pem`, `fcm_service_account_json`, `kamailio.password`, and
each user's `password`, like every other empty field. It also leaves
out the users of an upstream with `user_source: kamailio`.




## OpenAPI

````yaml /reference/openapi.yaml get /config/export
openapi: 3.1.0
info:
  title: pgw admin API
  version: 0.4.0
  description: |
    Manage a pgw tenant: its apps, upstreams, managed mode users, bindings,
    and push log.

    The API listens on `admin_listen`, `127.0.0.1:8080` by default, over plain
    HTTP. Every endpoint except `POST /bootstrap`, `POST /tls/reload`, and the
    register bans needs a tenant API key in the `Authorization` header. Those
    need the server's `PGW_BOOTSTRAP_TOKEN`. Request bodies are JSON objects
    of at most 1 MiB, or 16 MiB for `POST /config/sync`, and pgw rejects
    unknown fields. Responses are never cached.

    An unknown path gets `404`, and a method that the path doesn't serve gets
    `405` with an `Allow` header. Every `GET` endpoint also answers `HEAD`.
    An endpoint that needs an API key answers `500` when pgw can't check the
    key.

    The same listener also serves `GET /metrics`, `GET /healthz`, and
    `GET /readyz`, outside `/api/v1` and without authentication. The health
    checks and metrics pages describe them.
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
servers:
  - url: '{baseUrl}'
    description: Your pgw admin listener
    variables:
      baseUrl:
        default: http://127.0.0.1:8080/api/v1
        description: The address of admin_listen, followed by /api/v1.
  - url: http://localhost:8080/api/v1
    description: pgw on this computer
security:
  - apiKey: []
tags:
  - name: Tenant
    description: Create the first tenant and read the caller's tenant.
  - name: Apps
    description: Mobile and web apps and their push credentials.
  - name: Upstreams
    description: PBXs that pgw registers apps with.
  - name: Users
    description: >-
      SIP accounts that pgw checks itself and registers at the PBX in managed
      mode.
  - name: Bindings
    description: Devices registered through pgw.
  - name: Push events
    description: The log of push attempts.
  - name: TLS
    description: The certificate that pgw presents to apps.
  - name: Register bans
    description: >-
      Source addresses that pgw refuses REGISTERs from after too many refused
      credentials.
  - name: Config
    description: Export a tenant's configuration and make it match a snapshot.
paths:
  /config/export:
    get:
      tags:
        - Config
      summary: Export the tenant's configuration
      description: |
        Returns the tenant's apps, upstreams, and managed mode users as a
        snapshot that `POST /config/sync` accepts. Apps are sorted by
        platform and bundle ID, upstreams by host, and each upstream's users
        by domain, then username. pgw returns no secret: it leaves out
        `apns_key_pem`, `fcm_service_account_json`, `kamailio.password`, and
        each user's `password`, like every other empty field. It also leaves
        out the users of an upstream with `user_source: kamailio`.
      operationId: exportConfig
      responses:
        '200':
          description: The tenant's configuration, without secrets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Snapshot'
              example:
                apps:
                  - platform: android
                    bundle_id: com.example.phone
                    fcm_project_id: example-phone
                    fcm_project_number: '123456789012'
                  - platform: ios
                    bundle_id: com.example.phone
                    name: Example Phone
                    apns_team_id: ABCDE12345
                    apns_key_id: ABC123DEFG
                    apns_environment: production
                    delivery_mode: always_push
                upstreams:
                  - name: Main PBX
                    host: 192.0.2.10
                    domains:
                      - acme.example.com
                    port: 5060
                    transport: tcp
                    max_expires: 3600
                    strict_path: true
                    contact_strategy: masquerade
                    keepalive_seconds: 30
                    mode: managed
                    managed_registration: per_user
                    user_source: pgw
                    app_auth: both
                    bearer:
                      issuer: https://auth.example.com/
                      audience: pgw
                      jwks_url: https://auth.example.com/.well-known/jwks.json
                    users:
                      - username: '1001'
                        domain: acme.example.com
                        enabled: true
                      - username: '1002'
                        domain: acme.example.com
                        auth_username: acme-1002
                        enabled: false
                  - name: asterisk
                    host: pbx.example.com
                    domains:
                      - '*.example.com'
                    port: 5060
                    transport: udp
                    max_expires: 3600
                    invite_source_cidrs:
                      - 203.0.113.10/32
                    strict_path: true
                    contact_strategy: path
                    keepalive_seconds: 30
                    mode: passthrough
                    user_source: pgw
                    app_auth: digest
                    users: []
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    Snapshot:
      type: object
      required:
        - apps
        - upstreams
      description: >
        A tenant's configuration. The records use the fields of the create

        requests, except that a secret can be empty, which keeps the stored

        one. A `null` list leaves its records alone, even with `prune`. An empty
        list names the section with no records,

        so `prune` deletes every record of that kind. An export always

        sends `apps`, `upstreams`, and the `users` of each upstream whose

        users pgw stores.
      properties:
        apps:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/CreateAppRequest'
        upstreams:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/SnapshotUpstream'
    CreateAppRequest:
      type: object
      additionalProperties: false
      required:
        - platform
        - bundle_id
      properties:
        platform:
          type: string
          enum:
            - ios
            - android
            - web
        bundle_id:
          type: string
          description: >-
            The iOS bundle ID or the Android package name. For a web app, any
            label.
        name:
          type: string
          maxLength: 64
          description: >-
            A name for the app, which log lines show. Without one, log lines
            show the bundle ID. Up to 64 characters, with no control characters.
        apns_team_id:
          type: string
          description: The Apple team ID. Required for iOS.
        apns_key_id:
          type: string
          description: The APNs key ID. Required for iOS.
        apns_key_pem:
          type: string
          description: The contents of the APNs `.p8` key, a PKCS
          writeOnly: true
        apns_environment:
          type: string
          enum:
            - production
            - sandbox
          default: production
          description: Use `sandbox` for builds from Xcode.
        fcm_project_id:
          type: string
          description: >-
            The Firebase project ID. pgw sends pushes to this project. Required
            for Android. Must not be all digits.
        fcm_project_number:
          type: string
          pattern: ^[0-9]*$
          description: >-
            The Firebase project number. Optional, but Linphone identifies its
            project by this number, so a Linphone build needs it.
        fcm_service_account_json:
          type: string
          description: >-
            The contents of the Firebase service account key file. Required for
            Android.
          writeOnly: true
        vapid_subject:
          type: string
          description: >-
            A `mailto:` or `https:` URI that push services can use to contact
            you. Required for web.
        vapid_private_key_pem:
          type: string
          description: A P-256 private key in PEM, PKCS
          writeOnly: true
        delivery_mode:
          $ref: '#/components/schemas/DeliveryMode'
          description: Omit to use the gateway default.
        managed_refresh_push:
          type: string
          enum:
            - ''
            - 'on'
            - 'off'
          description: >-
            Whether pgw sends the app's managed iOS and Android devices a
            refresh push before their registration expires. Omit to use the
            gateway default.
    SnapshotUpstream:
      type: object
      additionalProperties: false
      required:
        - name
        - host
      description: |
        An upstream with its managed mode users beside its fields. The
        fields are those of `CreateUpstreamRequest`, except that
        `kamailio.password` can be left out, which keeps the stored one.
      properties:
        name: 472a7436-d1d6-4b6c-adcc-3c930bb2479b
        host: 8c8a87ed-6cd8-4aef-81b7-421735665273
        domains: fe1356b8-1ab0-489a-a342-5c02eac2c868
        port: 7f210873-e327-4693-9643-79eff2a203bd
        transport: ba89af5b-94dd-4333-a496-89046a6aab7e
        max_expires: 36acbfee-1138-476e-85d2-40b420c45dfe
        invite_source_cidrs: fd549961-b3ac-40bf-97a0-0d7313c62007
        strict_path: 9b9d54e7-1545-40ff-98ae-26d9f55f538f
        mode: 359b82d2-e748-4fd9-9eaf-5e76d5a54285
        keepalive_seconds: 5ad5094c-b9ae-41a6-80b4-298282a2ff49
        realm: cadcc87a-cf83-4a7c-946a-8488a79e04d3
        managed_registration: 884a5fa5-20c0-459f-9ef6-5cd17efc35df
        contact_strategy: 73da0495-27cc-4a89-adc7-d3080fae39ed
        user_source: f24beda4-3593-48bb-8b48-8ca893b186e4
        kamailio: d123f8d7-4bed-4956-90bf-14b8792ff7ed
        app_auth: 43e4cd2b-be29-429a-9eb3-4ba3cefdab93
        bearer: 49b650ef-2559-4f6b-b808-06c08d54c9ad
        users:
          type:
            - array
            - 'null'
          description: |
            The upstream's users. Not allowed with `user_source: kamailio`.
            When `null` or left out, `prune` leaves the upstream's users
            alone.
          items:
            $ref: '#/components/schemas/SnapshotUser'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: What went wrong. Never contains the values that you sent.
    DeliveryMode:
      type: string
      enum:
        - provisional
        - always_push
      description: |
        How pgw sends a call to an app that has an open connection.
        `provisional` sends the call on the connection and pushes if the app
        doesn't respond within `provisional_timeout`. `always_push` pushes for
        every call.
    SnapshotUser:
      type: object
      additionalProperties: false
      required:
        - username
      description: |
        A managed mode user in a snapshot. The fields are those of
        `CreateUserRequest`, except that `password` can be left out, which
        keeps the stored one. A new user needs a password.
      properties:
        username: 55423089-e547-430b-9dc9-94c350de4c70
        domain: 0d549928-82bc-4cc9-9c4c-0d880a355113
        auth_username: 3a0a6102-69f7-4f16-a406-a6d17655e27e
        password: e58d2491-2eeb-458e-8610-0ca8d179fcb1
        enabled: dd830a7d-4f5c-40b0-a0eb-6bf0426593c0
  responses:
    Unauthorized:
      description: The API key is missing or unknown.
      headers:
        WWW-Authenticate:
          schema:
            type: string
            const: Bearer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: missing or unknown API key
    InternalError:
      description: pgw failed to complete the request. The details are in pgw's log.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: internal error
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: The tenant API key that `POST /bootstrap` returned.

````

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