{
  "openapi": "3.1.0",
  "info": {
    "title": "Connections",
    "description": "Channel connections on the account. Use a connection's `_id` as `connectionId` when sending. Provider credentials are never returned.",
    "version": "1.0.0",
    "contact": {
      "name": "iClosed.io Support",
      "url": "https://app.iclosed.io/support"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://app.iclosed.io/terms"
    }
  },
  "servers": [
    {
      "url": "https://uinboxpub.api.iclosed.io",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "API key required in Authorization header. Format: `iclosed_<token>`"
      },
      "oauth2": {
        "type": "oauth2",
        "description": "OAuth 2.1 authorization code with PKCE. Tokens are issued by the iClosed authorization server and accepted by the Unified Inbox API.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://app.iclosed.io/oauth/authorize",
            "tokenUrl": "https://public.api.iclosed.io/v1/oauth/token",
            "refreshUrl": "https://public.api.iclosed.io/v1/oauth/token",
            "scopes": {
              "inbox.chats:read": "Read inbox chats",
              "inbox.chats:write": "Create, update and assign inbox chats",
              "inbox.messages:read": "Read inbox messages",
              "inbox.messages:write": "Send and retry inbox messages",
              "inbox.connections:read": "Read channel connections",
              "inbox.analytics:read": "Read inbox analytics",
              "inbox.recordings:read": "Read call recordings",
              "inbox.recordings:write": "Generate call recording summaries",
              "inbox.workflows:read": "Read inbox workflows"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/v1/connections/list": {
      "get": {
        "operationId": "listConnections",
        "security": [
          {
            "bearerAuth": [
              "inbox.connections:read"
            ]
          },
          {
            "oauth2": [
              "inbox.connections:read"
            ]
          }
        ],
        "summary": "List connections",
        "description": "Lists the channel connections on this account, grouped by channel type, with the id to pass as connectionId when sending. Provider credentials are never returned; sendRules carries the per-connection limits that apply to a send.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The account's channel connections, grouped by channel type.",
            "content": {
              "application/json": {
                "schema": {
                  "$schema": "http://json-schema.org/draft-07/schema#",
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "connections": {
                          "description": "Connections grouped by channel type. A type with no connections is absent.",
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "_id": {
                                  "description": "Pass this as connectionId when sending.",
                                  "type": "string"
                                },
                                "type": {
                                  "description": "Channel type, e.g. whatsappCloudApi, gmail, instagram.",
                                  "type": "string"
                                },
                                "name": {
                                  "description": "Connection name as shown in the inbox.",
                                  "type": "string"
                                },
                                "status": {
                                  "description": "Whether the connection is usable right now.",
                                  "type": "string"
                                },
                                "userId": {
                                  "description": "The teammate who connected it.",
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "phoneNumber": {
                                  "type": "string"
                                },
                                "phoneNumberId": {
                                  "description": "WhatsApp Cloud API.",
                                  "type": "string"
                                },
                                "businessAccountId": {
                                  "description": "WhatsApp Cloud API.",
                                  "type": "string"
                                },
                                "emailAddress": {
                                  "description": "Email channels.",
                                  "type": "string"
                                },
                                "senderName": {
                                  "type": "string"
                                },
                                "signatureActive": {
                                  "type": "boolean"
                                },
                                "signatureBody": {
                                  "type": "string"
                                },
                                "chatLink": {
                                  "type": "string"
                                },
                                "phoneLines": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "phoneLine": {
                                        "type": "string"
                                      },
                                      "limit": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "phoneLine",
                                      "limit"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "autoSwitchLine": {
                                  "type": "boolean"
                                },
                                "createChatOnUnknown": {
                                  "type": "boolean"
                                },
                                "dailyConversationsCap": {
                                  "description": "Per-day send cap for this connection.",
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "pageId": {
                                  "description": "Facebook Messenger.",
                                  "type": "string"
                                },
                                "pageName": {
                                  "description": "Facebook Messenger.",
                                  "type": "string"
                                },
                                "pageLink": {
                                  "description": "Facebook Messenger.",
                                  "type": "string"
                                },
                                "category": {
                                  "type": "string"
                                },
                                "instagramAccountId": {
                                  "type": "string"
                                },
                                "instagramUserId": {
                                  "type": "string"
                                },
                                "username": {
                                  "type": "string"
                                },
                                "workspaceId": {
                                  "type": "string"
                                },
                                "adminId": {
                                  "type": "string"
                                },
                                "visibleIntercomFields": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "sendRules": {
                                  "description": "The limits that apply to a send on this connection — caps, windows and opt-out handling.",
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                }
                              },
                              "required": [
                                "_id",
                                "type",
                                "name"
                              ],
                              "additionalProperties": false
                            }
                          }
                        }
                      },
                      "required": [
                        "connections"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Bad request or validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$schema": "http://json-schema.org/draft-07/schema#",
                  "type": "object",
                  "properties": {
                    "message": {
                      "description": "The first problem, as \"field: reason\". It is one of the entries in details, not a separate sentence.",
                      "type": "string"
                    },
                    "details": {
                      "description": "Present on a validation failure.",
                      "type": "object",
                      "properties": {
                        "formErrors": {
                          "description": "Problems with the request as a whole, which no single field accounts for.",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "fieldErrors": {
                          "description": "Field name to the problems with it. A field the endpoint does not accept is listed here under its own name, with \"Unrecognized key\".",
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "required": [
                        "formErrors",
                        "fieldErrors"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "invalidValue": {
                    "summary": "A field was out of range",
                    "value": {
                      "message": "limit: Too big: expected number to be <=500",
                      "details": {
                        "formErrors": [],
                        "fieldErrors": {
                          "limit": [
                            "Too big: expected number to be <=500"
                          ]
                        }
                      }
                    }
                  },
                  "unknownField": {
                    "summary": "The body carried a field the endpoint does not accept",
                    "value": {
                      "message": "notAField: Unrecognized key",
                      "details": {
                        "formErrors": [],
                        "fieldErrors": {
                          "notAField": [
                            "Unrecognized key"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – missing, invalid, or expired API key (Bearer token required). An expired key returns message \"API key expired\".",
            "content": {
              "application/json": {
                "schema": {
                  "$schema": "http://json-schema.org/draft-07/schema#",
                  "type": "object",
                  "properties": {
                    "message": {
                      "description": "e.g. \"API key is required\", \"Invalid API key\", or \"API key expired\"",
                      "type": "string"
                    },
                    "code": {
                      "description": "Optional code e.g. MISSING_API_KEY when rate limiter runs before valid auth",
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "missing": {
                    "summary": "Missing API key",
                    "value": {
                      "message": "API key is required"
                    }
                  },
                  "invalid": {
                    "summary": "Invalid API key",
                    "value": {
                      "message": "Invalid API key"
                    }
                  },
                  "expired": {
                    "summary": "Expired API key",
                    "value": {
                      "message": "API key expired"
                    }
                  },
                  "missingFromRateLimiter": {
                    "summary": "Missing auth when rate limiter runs first",
                    "value": {
                      "code": "MISSING_API_KEY",
                      "message": "API key is required for this endpoint"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$schema": "http://json-schema.org/draft-07/schema#",
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "message": "Forbidden access"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (e.g. NOT_FOUND, RECORD_NOT_FOUND, EVENT_NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$schema": "http://json-schema.org/draft-07/schema#",
                  "type": "object",
                  "properties": {
                    "message": {
                      "description": "e.g. \"Resource not found!\" or \"Record not found!\"",
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "generic": {
                    "summary": "Generic not found",
                    "value": {
                      "message": "Resource not found!"
                    }
                  },
                  "record": {
                    "summary": "Record not found",
                    "value": {
                      "message": "Record not found!"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Each plan has its own allowance per endpoint per 10 seconds: Startup 20, Growth 50, Business 100. Response includes RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, and Retry-After headers.",
            "headers": {
              "RateLimit-Limit": {
                "description": "Maximum requests allowed in the current window",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Remaining": {
                "description": "Requests remaining in the current window",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Reset": {
                "description": "ISO 8601 timestamp when the rate limit window resets",
                "schema": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "Retry-After": {
                "description": "Seconds until the client can retry (when applicable)",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$schema": "http://json-schema.org/draft-07/schema#",
                  "type": "object",
                  "properties": {
                    "code": {
                      "description": "Fixed code for rate limit responses",
                      "type": "string",
                      "const": "RATE_LIMIT_EXCEEDED"
                    },
                    "message": {
                      "description": "e.g. \"Too many requests, please try again later.\"",
                      "type": "string"
                    },
                    "retryAfter": {
                      "description": "Seconds until the rate limit window resets",
                      "type": "number"
                    },
                    "limit": {
                      "description": "The plan limit that was applied, per endpoint per 10 seconds: Startup 20, Growth 50, Business 100.",
                      "type": "object",
                      "properties": {
                        "points": {
                          "type": "number"
                        },
                        "windowSec": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "points",
                        "windowSec"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "code": "RATE_LIMIT_EXCEEDED",
                  "message": "Too many requests, please try again later.",
                  "retryAfter": 10,
                  "limit": {
                    "points": 20,
                    "windowSec": 10
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Unhandled errors return a generic message; no stack trace is ever returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$schema": "http://json-schema.org/draft-07/schema#",
                  "type": "object",
                  "properties": {
                    "message": {
                      "description": "Generic: \"Something went wrong\", or a safe error message",
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "additionalProperties": false
                },
                "examples": {
                  "generic": {
                    "summary": "Generic",
                    "value": {
                      "message": "Something went wrong"
                    }
                  },
                  "withMessage": {
                    "summary": "Error with message",
                    "value": {
                      "message": "Database connection failed"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}