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

# Import a connection

> Connects a Facebook Page or Instagram account from an access token you
already hold, without sending the customer through an authorization
screen again.

This is for one situation: a platform moving existing connections onto
Nylon. `POST /v1/connections` is the normal way in, and it asks a human
to approve, because that is the only way a token can be granted. Use
this only for tokens that were already granted to the Meta app Nylon is
configured with — your own, under Platform keys.

The token is verified against Meta before anything is stored, so a
stale one is refused here rather than at the first publish. Re-running
an import refreshes the connection instead of duplicating it.




## OpenAPI

````yaml /openapi.yaml post /v1/connections/import
openapi: 3.1.0
info:
  title: Nylon API
  version: 1.0.0
  description: |
    One API for publishing to seventeen social networks.

    You address a post to connected profile ids; Nylon knows which network each
    one belongs to, what that network accepts, and how to get the media there.
    Character limits, media specs, upload protocols and threading rules are
    normalised before the request reaches a platform, and every failure comes
    back in one error taxonomy.

    ## Conventions

    - Request and response fields are `snake_case`.
    - Successful responses wrap the payload in `data`. List responses add
      `meta.pagination`.
    - Failures return `{ "error": { "code", "message", "details?" } }`.
      Branch on `code`; `message` is written for humans and may change.
    - Times are ISO 8601 with a `Z` offset.
    - Successful responses carry `RateLimit-Limit`, `RateLimit-Remaining` and
      `RateLimit-Reset`. A `429` carries those plus `Retry-After`.
servers:
  - url: https://api.nylon.dev
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Posts
    description: Create, schedule, validate, inspect, edit and retry posts.
  - name: Profiles
    description: Social profiles connected to the authenticated Nylon account.
  - name: Connections
    description: Start a connection and see which networks are available.
  - name: Networks
    description: What each network accepts, as data.
  - name: Webhooks
    description: Endpoints Nylon calls when a post finishes or a profile stops working.
  - name: Media
    description: >-
      Getting a file to a URL a network can fetch, when you do not already host
      one.
  - name: Inbox
    description: >-
      Direct messages and comment threads on the connected accounts, and replies
      to them.
paths:
  /v1/connections/import:
    post:
      tags:
        - Connections
      summary: Import a connection
      description: |
        Connects a Facebook Page or Instagram account from an access token you
        already hold, without sending the customer through an authorization
        screen again.

        This is for one situation: a platform moving existing connections onto
        Nylon. `POST /v1/connections` is the normal way in, and it asks a human
        to approve, because that is the only way a token can be granted. Use
        this only for tokens that were already granted to the Meta app Nylon is
        configured with — your own, under Platform keys.

        The token is verified against Meta before anything is stored, so a
        stale one is refused here rather than at the first publish. Re-running
        an import refreshes the connection instead of duplicating it.
      operationId: importConnection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - network
                - external_id
                - access_token
              properties:
                network:
                  type: string
                  enum:
                    - facebook
                    - instagram
                external_id:
                  type: string
                  description: >-
                    The account's id on the network — a Page id, an Instagram
                    account id.
                  example: '102938475610111'
                access_token:
                  type: string
                  description: >-
                    The Page access token. Instagram authenticates with the
                    token of the Page it is linked to, so both networks want the
                    Page's.
                page_id:
                  type:
                    - string
                    - 'null'
                  description: >-
                    The Page an Instagram account is linked to. Worked out from
                    the token when omitted.
                page_name:
                  type:
                    - string
                    - 'null'
      responses:
        '200':
          description: The connected account.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Profile'
        '400':
          description: Meta refused the token, or the id does not match it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    Profile:
      type: object
      required:
        - id
        - network
        - external_id
        - name
        - status
        - suspended
        - connected_at
      properties:
        id:
          type: string
          description: >-
            Stable Nylon identifier for the connected profile. This is what you
            address a post to.
          example: cly7p2q4k0001x8b3f2n9d0aa
        network:
          $ref: '#/components/schemas/Network'
        external_id:
          type: string
          description: The network's own identifier for the account.
          example: '17841400000000000'
        name:
          type: string
          description: Display name of the connected profile.
          example: Nylon Studio
        handle:
          type:
            - string
            - 'null'
          description: Network username without a leading @, when the network has one.
          example: nylonstudio
        avatar_url:
          type:
            - string
            - 'null'
          format: uri
          example: https://cdn.example.com/avatar.jpg
        profile_url:
          type:
            - string
            - 'null'
          format: uri
          example: https://www.instagram.com/nylonstudio
        status:
          type: string
          description: |
            `active` is healthy. `needs_attention` means the stored credentials
            stopped working and the customer has to reconnect in Nylon.
          enum:
            - active
            - needs_attention
          example: active
        suspended:
          type: boolean
          description: |
            True when the profile is beyond the free allowance and billing is
            not active. It is still listed and still connected, but publishing
            to it is refused with `402`.
          example: false
        connected_at:
          type: string
          format: date-time
          example: '2026-05-14T10:20:00.000Z'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/Error'
    Network:
      type: string
      description: A network Nylon publishes to.
      enum:
        - facebook
        - instagram
        - x
        - linkedin
        - pinterest
        - bluesky
        - threads
        - tiktok
        - youtube
        - google_business
        - mastodon
        - discord
        - dribbble
        - kick
        - twitch
        - whop
        - devto
      example: instagram
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: The stable identifier to branch on.
          enum:
            - invalid_request
            - unauthorized
            - payment_required
            - forbidden
            - not_found
            - conflict
            - rate_limited
            - unsupported
            - publish_failed
            - internal_error
          example: unauthorized
        message:
          type: string
          description: Written for humans. Do not match on it.
          example: A valid Nylon API key is required.
        details:
          type: array
          description: Present when the failure has a per-field or per-network breakdown.
          items:
            $ref: '#/components/schemas/ErrorDetail'
    ErrorDetail:
      type: object
      required:
        - message
      properties:
        field:
          type: string
          description: The request field the problem is about.
          example: profile_ids
        network:
          type: string
          description: The network the problem is about.
          example: instagram
        code:
          type: string
          description: |
            Machine-readable identifier for this problem. On a per-network
            detail this is a publishing code: `invalid_request`,
            `unsupported`, `media_error`, `reauthentication_required`,
            `rejected_by_network`, `network_error`, `timeout`,
            `profile_unavailable` or `internal_error`.
          example: invalid_request
        message:
          type: string
          example: >-
            Instagram requires at least 1 media item — text-only posts are not
            supported.
  responses:
    Unauthorized:
      description: The bearer API key is missing, malformed or revoked.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingKey:
              value:
                error:
                  code: unauthorized
                  message: A valid Nylon API key is required.
    PaymentRequired:
      description: |
        Billing is blocking the action. Most often an addressed profile is
        beyond the free allowance while the subscription is inactive — it is
        still connected and still listed with `suspended: true`, but nothing
        can be published through it until billing restarts.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            suspended:
              value:
                error:
                  code: payment_required
                  message: >-
                    Nylon Studio is beyond your free allowance and your
                    subscription is not active. Restart billing to publish
                    through them again.
    RateLimited:
      description: |
        Too many requests for this API key. Reads allow 120 requests a minute;
        publishing endpoints allow 30, because each one costs real upstream
        calls. The limit is per key, not per IP.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            throttled:
              value:
                error:
                  code: rate_limited
                  message: Too many requests. Retry after the window resets.
    InternalError:
      description: Nylon encountered an unexpected error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  headers:
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
        example: 47
    RateLimitLimit:
      description: Requests allowed in the current window.
      schema:
        type: integer
        example: 120
    RateLimitRemaining:
      description: Requests left in the current window.
      schema:
        type: integer
        example: 119
    RateLimitReset:
      description: Seconds until the window resets.
      schema:
        type: integer
        example: 47
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Nylon API key
      description: An API key beginning with `nylon_live_`.

````

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