> For the complete documentation index, see [llms.txt](https://predictbase.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://predictbase.gitbook.io/docs/developer/endpoints/create-a-market.md).

# Create a Market

Creates a new prediction market on **PredictBase.** A **market creation fee of 1 USDC** is automatically **deducted from the creator’s PredictBase balance** when the transaction is submitted.

***

#### **Endpoint**

```http
POST /create-market-for-user
```

**Full URL**

```
https://api.predictbase.app/create-market-for-user
```

***

#### Authentication

This endpoint requires **authentication**. You must include your **API key** in the request **headers**:

```
x-api-key: YOUR_API_KEY
```

The API key must be **authorized for the `creator` address**.

***

#### Request Body

```json
{
  "creator": "0xCreatorAddress",
  "question": "Will BTC be above $100k by 2026?",
  "optionTitles": ["Yes", "No"],
  "optionImages": ["", ""],
  "categories": ["Crypto", "BTC"],
  "details": "Longer description / rules",
  "image": "https://.../market-hero.png",
  "endDate": "1735689600",
}
```

***

#### Field Notes

* **`creator`**\
  Wallet address that will own and manage the market
* **`endDate`**\
  Unix timestamp in **seconds** (`uint64`, string or number)
* **`optionTitles`**\
  Titles for each market option (e.g. `["Yes", "No"]`)
* **`optionImages`** *(Optional)*\
  Image URLs for each option. This field is **not implemented yet** and is currently ignored if provided.

***

#### Response (Success)

```json
{
  "success": true,
  "txHash": "0x...",
  "receipt": {
    "...": "EVM transaction receipt fields"
  }
}
```

***

#### Pending Receipt

```json
{
  "success": true,
  "txHash": "0x...",
  "receipt": null,
  "warning": "Tx sent but receipt not yet available"
}
```

***

#### ⚠️ Failure Cases

* Missing or invalid `x-api-key`
* API key not authorized for the `creator`
* Insufficient balance to cover the **1 USDC market creation fee**
* Invalid market parameters
* On-chain transaction failure
