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

# enrollUserToMarketDeployer: Join a Market Deployer

> Enroll your account in a market deployer before trading its contracts or transferring collateral in multi-market-deployer setups on Upside .

A **market deployer** is an isolated trading environment with its own smart contract set and collateral pool. When you register your account, Upside automatically enrolls you in the default (bootstrap) market deployer. If you want to trade contracts belonging to a different market deployer, or transfer collateral to one, you must explicitly enroll in it first using the `enrollUserToMarketDeployer` action.

This action is **idempotent**: submitting it when you are already enrolled does not produce an error — the server simply returns `enrolled: false` to indicate no new enrollment was created. You can safely call it as a precondition check before any market-deployer-specific operation.

<Note>
  You must have a registered account before calling this action. If the signing wallet has not been registered, the server returns HTTP 400.
</Note>

## Prerequisites

* A registered account (see [`registerAccount`](/exchange/register-account))
* The numeric ID of the market deployer you want to join

## Request

```text theme={"system"}
POST https://dev.upsidemax.xyz/exchange
Content-Type: application/json
```

```json theme={"system"}
{
  "action": {
    "type": "enrollUserToMarketDeployer",
    "marketDeployerId": 2
  },
  "signature": { "r": "0x...", "s": "0x...", "v": 28 },
  "nonce": 1778572816871
}
```

### Action Fields

<ParamField body="type" type="string" required>
  Must be the fixed string `"enrollUserToMarketDeployer"`.
</ParamField>

<ParamField body="marketDeployerId" type="int32" required>
  The numeric identifier of the market deployer you want to enroll in. Contact the market deployer operator or query the read API to discover available IDs.
</ParamField>

## Response

```json theme={"system"}
{
  "status": "ok",
  "requestId": "req-144115188075855890",
  "response": {
    "type": "enrollUserToMarketDeployer",
    "data": {
      "marketDeployerId": 2,
      "enrolled": true
    }
  }
}
```

### Response Fields

<ResponseField name="marketDeployerId" type="int32">
  The market deployer the account is now enrolled in, echoing the requested ID.
</ResponseField>

<ResponseField name="enrolled" type="boolean">
  `true` if this is the first time your account has enrolled in the specified market deployer. `false` if you were already enrolled — this is not an error; the operation is idempotent.
</ResponseField>

<ResponseField name="errorCode" type="integer">
  A non-zero value indicates a business-level rejection. `0` or absent means success. Check this field even when `status` is `"ok"`.
</ResponseField>

<ResponseField name="errorMessage" type="string">
  A human-readable description of the rejection when `errorCode` is non-zero. For example: `"unknown marketDeployer"` when the requested ID does not exist.
</ResponseField>

<Note>
  `"status": "ok"` confirms the request was received and processed by the server. It does **not** guarantee enrollment succeeded. Always inspect `errorCode` and `errorMessage` inside `response.data` to confirm the business outcome — for example, passing an unknown `marketDeployerId` returns `status: "ok"` with a non-zero `errorCode`.
</Note>

## Error Reference

| Condition               | Indicated By                                               | Description                                                            |
| ----------------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------- |
| Unknown market deployer | `errorCode != 0`, `errorMessage: "unknown marketDeployer"` | The `marketDeployerId` does not correspond to any registered deployer. |
| Unregistered account    | HTTP 400                                                   | The signing wallet has not called `registerAccount` yet.               |
| Already enrolled        | `enrolled: false`                                          | Not an error — enrollment is idempotent.                               |

<Warning>
  Do not confuse a business rejection (`errorCode != 0` inside the response body) with an HTTP error. The server returns HTTP 200 for both successful enrollments and unknown-deployer rejections. Your client must always read `errorCode` to determine the true outcome.
</Warning>

## Next Steps

<Steps>
  <Step title="Verify enrollment">
    Check that `enrolled: true` (or `enrolled: false` if you expected to already be enrolled) and that `errorCode` is `0` or absent.
  </Step>

  <Step title="Lock collateral into the deployer">
    Use [`lockCollateral`](/exchange/lock-collateral) to deposit funds into the market deployer's collateral pool before placing orders.
  </Step>

  <Step title="Start trading">
    With collateral locked, you can now place orders on contracts belonging to this market deployer using the [`order`](/exchange/order) action.
  </Step>
</Steps>
