# Purchase

The following documentation outlines the API endpoints and their respective functionalities for validating and processing in-app purchases using Telegram invoices.

## CreateTelegramInvoice

This function is used to create a Telegram invoice link.

#### URL:

```
POST /api/{titleTemplateId}/{titleId}/Client/Purchase/CreateTelegramInvoice  
```

#### Request Parameters:

* `CreateInvoiceRequest` (JSON body): The request payload containing the invoice details.

#### JSON Body:

* `title` (string): The title of the invoice.
* `description` (string): The description of the invoice.
* `payload` (string): The payload of the invoice.
* `provider_token` (string): The provider token.
* `currency` (string): The currency of the invoice.
* `prices` (array): The list of prices in the specified currency.

#### Responses:

* **200 OK**: Returns the Telegram invoice link.
* **400 Bad Request**: Returns an error message if the request is invalid.

#### Example Usage:

```javascript
fetch('https://api.idosgames.com/api/{titleTemplateId}/{titleId}/Client/Purchase/CreateTelegramInvoice', {    
    method: 'POST',    
    headers: {    
        'Content-Type': 'application/json'    
    },    
    body: JSON.stringify({    
        title: 'Game Purchase',    
        description: 'In-game currency purchase',    
        payload: 'unique-payload',    
        provider_token: 'provider-token',    
        currency: 'USD',    
        prices: [{ label: '100 Coins', amount: 1000 }]    
    })    
})    
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

#### Response Example:

```json
{  
    "ok": true,  
    "result": "https://t.me/invoice_link"  
}  
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.idosgames.com/api/api-v1/purchase.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
