> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.walletstech.com/llms.txt.
> For full documentation content, see https://docs.walletstech.com/llms-full.txt.

# Create buy transaction by crypto

POST https://buy/new
Content-Type: application/json

Reference: https://docs.walletstech.com/api/buy/create-buy-transaction-by-crypto

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /buy/new:
    post:
      operationId: create-buy-transaction-by-crypto
      summary: Create buy transaction by crypto
      tags:
        - subpackage_buy
      parameters:
        - name: X-AUTH-TOKEN
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Buy_Create buy transaction by
                  crypto_Response_200
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                type:
                  type: integer
                user:
                  type: integer
                amount:
                  type: string
                c_type:
                  type: integer
                f_type:
                  type: integer
                address:
                  type: string
              required:
                - type
                - user
                - amount
                - c_type
                - f_type
                - address
servers:
  - url: https:/
components:
  schemas:
    Buy_Create buy transaction by crypto_Response_200:
      type: object
      properties:
        id:
          type: integer
        rate:
          type: string
        c_type:
          type: string
        f_type:
          type: string
        status:
          type: string
        address:
          type: string
        c_amount:
          type: string
        f_amount:
          type: string
      required:
        - id
        - rate
        - c_type
        - f_type
        - status
        - address
        - c_amount
        - f_amount
      title: Buy_Create buy transaction by crypto_Response_200
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-AUTH-TOKEN

```

## SDK Code Examples

```python Buy_Create buy transaction by crypto_example
import requests

url = "https://https/buy/new"

payload = {
    "type": 2,
    "user": 1,
    "amount": "0.001",
    "c_type": 1,
    "f_type": 1,
    "address": "bc1......."
}
headers = {
    "X-AUTH-TOKEN": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Buy_Create buy transaction by crypto_example
const url = 'https://https/buy/new';
const options = {
  method: 'POST',
  headers: {'X-AUTH-TOKEN': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"type":2,"user":1,"amount":"0.001","c_type":1,"f_type":1,"address":"bc1......."}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Buy_Create buy transaction by crypto_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://https/buy/new"

	payload := strings.NewReader("{\n  \"type\": 2,\n  \"user\": 1,\n  \"amount\": \"0.001\",\n  \"c_type\": 1,\n  \"f_type\": 1,\n  \"address\": \"bc1.......\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-AUTH-TOKEN", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Buy_Create buy transaction by crypto_example
require 'uri'
require 'net/http'

url = URI("https://https/buy/new")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-AUTH-TOKEN"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"type\": 2,\n  \"user\": 1,\n  \"amount\": \"0.001\",\n  \"c_type\": 1,\n  \"f_type\": 1,\n  \"address\": \"bc1.......\"\n}"

response = http.request(request)
puts response.read_body
```

```java Buy_Create buy transaction by crypto_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://https/buy/new")
  .header("X-AUTH-TOKEN", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"type\": 2,\n  \"user\": 1,\n  \"amount\": \"0.001\",\n  \"c_type\": 1,\n  \"f_type\": 1,\n  \"address\": \"bc1.......\"\n}")
  .asString();
```

```php Buy_Create buy transaction by crypto_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://https/buy/new', [
  'body' => '{
  "type": 2,
  "user": 1,
  "amount": "0.001",
  "c_type": 1,
  "f_type": 1,
  "address": "bc1......."
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-AUTH-TOKEN' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Buy_Create buy transaction by crypto_example
using RestSharp;

var client = new RestClient("https://https/buy/new");
var request = new RestRequest(Method.POST);
request.AddHeader("X-AUTH-TOKEN", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"type\": 2,\n  \"user\": 1,\n  \"amount\": \"0.001\",\n  \"c_type\": 1,\n  \"f_type\": 1,\n  \"address\": \"bc1.......\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Buy_Create buy transaction by crypto_example
import Foundation

let headers = [
  "X-AUTH-TOKEN": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "type": 2,
  "user": 1,
  "amount": "0.001",
  "c_type": 1,
  "f_type": 1,
  "address": "bc1......."
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://https/buy/new")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```