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

# Get Chain Activation Signable Message (Stage 1)

> Stage 1 of the two-stage chain-activation flow — returns the signable message for adding new chains to an existing portfolio.

Stage 1 of the two-stage chain-activation flow. A portfolio's chains are
chosen at enrollment (`chainIds` on `POST /v2/enroll`); this flow adds
smart accounts on **additional** chains to an already-enrolled portfolio.

The endpoint recomputes the session-key message over the requested (new)
chains from the portfolio's existing owner wallet, operating agent, and
account index, and returns it for the **portfolio owner** to sign — the
same signature ceremony as enrollment. The message shape follows the
portfolio's account type (determined server-side from how it was
enrolled):

* **ECDSA portfolios** get `{ "kind": "ecdsa", "raw": ... }` — a 32-byte
  digest covering all requested chains, signed via EIP-191
  `personal_sign`.
* **ERC-1271 portfolios** get `{ "kind": "typed-data", "typedData": ... }`
  — an EIP-712 payload signed with the owner's smart-contract wallet.
  One signature covers exactly one chain, so `chainIds` must contain
  exactly one entry.

Pass the signature to `POST /v2/portfolios/{portfolioId}/chains` to
activate.

* Auth: `x-api-key` header (required)
* Scope: `portfolios:write`

The call is **stateless and deterministic**: nothing is reserved, and
repeating it with the same `chainIds` returns the same message. There is
no expiry — the signature stays valid until submitted.

Current constraints:

* **EVM portfolios only.** Solana portfolios return `400`.
* ERC-1271 portfolios activate one chain per request; passing more than
  one `chainIds` entry returns `400`. To activate several chains, repeat
  the two-stage flow once per chain.
* `chainIds` must not contain duplicates and must not include chains the
  portfolio already has a smart account on — check `smartAccounts` on
  `GET /v2/portfolios/{portfolioId}` first.
* Unknown/unconfigured chains are rejected with `400`; the allowed list is
  in the error `details`.

Common error responses:

* `400` when the body is invalid, a chain is already active, a chain is
  unsupported, the portfolio is Solana, or more than one chain is
  requested on an ERC-1271 portfolio
* `401` when `x-api-key` is missing or invalid
* `403` when the API key lacks the `portfolios:write` scope
* `404` when the portfolio does not exist or belongs to another tenant

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.glider.fi/v2/portfolios/pf_01JWZEE2MF30KVRMRX53N88VA4/chains/signature' \
    --header 'x-api-key: gldr_sk_your_api_key' \
    --header 'Content-Type: application/json' \
    --data '{
      "chainIds": [42161]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.glider.fi/v2/portfolios/pf_01JWZEE2MF30KVRMRX53N88VA4/chains/signature",
    {
      method: "POST",
      headers: {
        "x-api-key": "gldr_sk_your_api_key",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ chainIds: [42161] }),
    },
  );
  ```
</RequestExample>

<ResponseExample>
  ```json 200 (ECDSA portfolio) theme={null}
  {
    "success": true,
    "data": {
      "message": {
        "kind": "ecdsa",
        "raw": "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
      }
    }
  }
  ```

  ```json 200 (ERC-1271 portfolio) theme={null}
  {
    "success": true,
    "data": {
      "message": {
        "kind": "typed-data",
        "typedData": {
          "domain": {
            "name": "ERC1271Validator",
            "version": "0.0.1",
            "chainId": 42161,
            "verifyingContract": "0x9999999999999999999999999999999999999999"
          },
          "types": {
            "MessageHash": [{ "name": "hash", "type": "bytes32" }]
          },
          "primaryType": "MessageHash",
          "message": {
            "hash": "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
          }
        }
      }
    }
  }
  ```

  ```json 400 (chain already active) theme={null}
  {
    "success": false,
    "error": {
      "code": "API_400",
      "message": "Portfolio already has a vault on chain(s): [42161]"
    }
  }
  ```

  ```json 404 theme={null}
  {
    "success": false,
    "error": {
      "code": "API_200",
      "message": "Portfolio with ID pf_01JWZEE2MF30KVRMRX53N88VA4 not found"
    }
  }
  ```
</ResponseExample>
