---
title: "Connect LINE Official Account"
method: POST
path: "/v1/connect/line/credentials"
tags: ["Connect"]
---

# Connect LINE Official Account

`POST /v1/connect/line/credentials`

## Request

- Base URL: `https://zernio.com/api`
- URL: `https://zernio.com/api/v1/connect/line/credentials`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/zernio/apis/zernio-api/docs/v1/connect/line/credentials/post.ts> (a function with typed inputs; its response is checked against the schema)

Connect a LINE Official Account with the Channel ID and Channel secret of its Messaging API channel (LINE Official Account Manager > Settings > Messaging API, also shown in the LINE Developers Console under the channel's Basic settings).

Zernio issues a channel access token, reads the bot's profile and sets the channel's webhook URL for you. A channel has one webhook URL, so if it already pointed somewhere else, that integration stops receiving events; the response names it in `webhook.previousUrl`.

Two settings stay on the customer's side, in LINE Official Account Manager > Settings > Response settings. `nextSteps` in the response lists them:

- Turn on Webhooks. Until it is on, LINE delivers nothing to Zernio.
- Turn off auto-response and greeting messages.

Reconnecting the same channel on the same profile updates the existing account.
To get your userId for the state parameter, call GET /v1/users which includes a currentUserId field.

## Request body

- object
  - `channelId` string, required: The Messaging API channel's Channel ID (digits only).
  - `channelSecret` string, required: The Messaging API channel's Channel secret (32 hex characters).
  - `state` string, required: Required state formatted as {userId}-{profileId}. Get userId from GET /v1/users and profileId from GET /v1/profiles.
  - `redirect_url` string, uri: Optional URL to redirect to after a successful connection.

## Response `200`

LINE connected

- object
  - `message` string
  - `account` ConnectedMessagingAccount: The account a credentials connect created or updated.
    - `accountId` string
    - `platform` 'line' | 'wechat'
    - `username` string: The LINE basic ID (for example @123abcde) or the WeChat AppID.
    - `displayName` string
    - `isActive` boolean
  - `webhook` object
    - `url` string, uri: The webhook URL Zernio set on the channel.
    - `configured` boolean: Whether LINE accepted the webhook URL. When false, paste `url` into the LINE Developers Console > Messaging API > Webhook URL yourself.
    - `testSucceeded` boolean: Whether LINE's webhook test call reached Zernio.
    - `detail` string: What LINE answered when the setup or the test did not succeed.
    - `previousUrl` string: Present when the channel pointed at another webhook URL before this connect. LINE allows one webhook URL per channel, so that URL stopped receiving events once Zernio set its own; `nextSteps` says so too.
  - `nextSteps` string[]: Settings the account owner still has to change in LINE Official Account Manager, led by a warning when `webhook.previousUrl` is set.
  - `redirectUrl` string

## Other responses

- `400`: Invalid request. `code` is `invalid_field_value` with `param` `channelSecret` when LINE rejected the Channel ID and Channel secret.
- `401`: Missing or invalid API key. `code` is `missing_credentials` when no Authorization header was sent and `invalid_credentials` when the key is unknown, revoked or expired.
- `403`: The connect token was issued for a different profile or platform (INSUFFICIENT_PERMISSIONS).

## Changes

- **2026-11-11** `d908988b0be8`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/zernio/apis/zernio-api/changes/v1/connect/line/credentials/post.md)

---

[API](https://skmtc.dev/zernio/apis/zernio-api.md) - [All operations](https://skmtc.dev/zernio/apis/zernio-api/llms.txt) - [OpenAPI document](https://skmtc.dev/zernio/apis/zernio-api/revisions/4dad246447be?raw)
