> For the complete documentation index, see [llms.txt](https://docs.heyhal.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.heyhal.xyz/api-documentation/create-token.md).

# Create Token

Endpoint: <mark style="color:yellow;">`POST /api/v1/coin/create`</mark><br>

**Description**

This endpoint creates a new token with a bonding curve configuration. It handles the token metadata, image upload, and initializes the token in the system.

**Authentication Required:** Yes<br>

**Type:** Bearer Token (JWT)<br>

**Request Headers**

Content-Type: multipart/form-data

Authorization: Bearer \<your\_jwt\_token><br>

**Body Parameters**

| Parameter              | Type   | Required | Description                                      |
| ---------------------- | ------ | -------- | ------------------------------------------------ |
| name                   | string | Yes      | The name of the token                            |
| symbol                 | string | Yes      | The symbol/ticker of the token                   |
| description            | string | Yes      | A description of the token                       |
| personality            | string | Yes      | Personality traits of the token's AI agent       |
| instruction            | string | Yes      | Instructions for the token's AI agent            |
| knowledge              | string | Yes      | Knowledge base for the token's AI agent          |
| twitter                | string | No       | Twitter handle associated with the token         |
| telegram               | string | No       | Telegram group/channel associated with the token |
| website                | string | No       | Website URL associated with the token            |
| image                  | file   | Yes      | Image file for the token's logo                  |
| creatorTwitterUsername | string | No       | Twitter username of the token creator            |
| creatorTwitterUserId   | string | No       | Twitter user ID of the token creator             |

\
**Response**

Success Response

**Status Code:** 200 OK

<br>

Content-Type: application/json

`{`

&#x20; `"success": true,`

&#x20; `"token": {`

&#x20;   `"mintAddress": "string",`

&#x20;   `"name": "string",`

&#x20;   `"symbol": "string",`

&#x20;   `"description": "string",`

&#x20;   `"metaDataUrl": "string",`

&#x20;   `"imageUrl": "string",`

&#x20;   `"creatorWalletAddress": "string",`

&#x20;   `"status": "string",`

&#x20;   `"tx": "string",`

&#x20;   `"signature": "string",`

&#x20;   `"createdAt": "string (ISO 8601 date)",`

&#x20;   `"updatedAt": "string (ISO 8601 date)"`

&#x20; `}`

`}`

<br>

Error Response

Status Code: 500 Internal Server Error

`Content-Type: application/json`

`{`

&#x20; `"error": "An internal error occurred. Please try again later."`

`}`

<br>

**Example Usage**

Here's an example of how to use this endpoint using JavaScript and the fetch API:

`async function createToken(tokenData, imageFile, jwt) {`

&#x20; `const formData = new FormData();`

&#x20;&#x20;

&#x20; // Append token data

&#x20; `Object.keys(tokenData).forEach(key => {`

&#x20;   `formData.append(key, tokenData[key]);`

&#x20; `});`

&#x20;&#x20;

&#x20; // Append image file

&#x20; `formData.append('image', imageFile);`

&#x20; `try {`

&#x20;   `const response = await fetch('https://api.heyhal.xyz/api/v1/coin/create', {`

&#x20;     `method: 'POST',`

&#x20;     `headers: {`

&#x20;       `` 'Authorization': `Bearer ${jwt}` ``

&#x20;     `},`

&#x20;     `body: formData`

&#x20;   `});`

&#x20;   `if (!response.ok) {`

&#x20;     ``throw new Error(`HTTP error! status: ${response.status}`);``

&#x20;   `}`

&#x20;   `const data = await response.json();`

&#x20;   `console.log('Token created successfully:', data);`

&#x20;   `return data;`

&#x20; `} catch (error) {`

&#x20;   `console.error('Error creating token:', error);`

&#x20;   `throw error;`

&#x20; `}`

`}`

// Usage

`const tokenData = {`

&#x20; `name: 'My Awesome Token',`

&#x20; `symbol: 'MAT',`

&#x20; `description: 'This is an awesome token for awesome people',`

&#x20; `personality: 'Friendly and helpful',`

&#x20; `instruction: 'Assist users with token-related queries',`

&#x20; `knowledge: 'Blockchain, DeFi, and tokenomics',`

&#x20; `twitter: '@myawesometoken',`

&#x20; `telegram: 't.me/myawesometoken',`

&#x20; `website: 'https://myawesometoken.com'`

`};`

`const imageFile = /* File object for the token image */;`

`const jwt = 'your_jwt_token_here';`

`createToken(tokenData, imageFile, jwt)`

&#x20; `.then(result => {`

&#x20;   `// Handle successful token creation`

&#x20; `})`

&#x20; `.catch(error => {`

&#x20;   `// Handle error`

&#x20; `});`

<br>

**Notes**

The image file should be a valid image format (e.g., PNG, JPG, GIF) and should not exceed the server's file size limit. The JWT token must be obtained through the authentication process before making this request. After successful token creation, you may need to wait for the blockchain transaction to be confirmed before the token is fully operational.

**Related WebSocket Events**

After creating a token, you can listen for the following WebSocket event to get real-time updates on the token creation process:

Event: `token_creation`

Payload:

`{`

&#x20; `"mintAddress": "string",`

&#x20; `"status": "string",`

&#x20; `"tx": "string"`

`}`<br>

The status field will be updated as the token creation progresses through various stages (e.g., "pending", "minting", "completed").

<br>
