# Send Transaction (POST)

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://bitcoin-mainnet.g.alchemy.com/v2/{apiKey}/api/v2/sendtx/

Broadcasts a signed raw Bitcoin transaction by sending hex bytes in the request body. The trailing slash on the path is mandatory; see the [Blockbook API reference](https://github.com/trezor/blockbook/blob/master/docs/api.md#send-transaction). Use this for larger payloads (request body limit 8 MiB). Returns the transaction ID on success.

> **Heads up**: the POST variant currently returns `{ "error": "Parse error" }` (HTTP 400) > on the Alchemy proxy regardless of body format. Until that upstream issue is resolved, > prefer the GET variant above for hex payloads under the URL-length limit.


Reference: https://www.alchemy.com/docs/chains/bitcoin/utxo-api-endpoints/utxo-api-endpoints/send-transaction-post

## Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| apiKey | string | Yes | For higher throughput, [create your own API key](https://dashboard.alchemy.com/signup) |

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/sendtx/
```

### JavaScript

```javascript
const options = {method: 'POST'};

fetch('https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/sendtx/', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/sendtx/"

response = requests.post(url)

print(response.text)
```

### Go

```go
package main

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

func main() {

	url := "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/sendtx/"

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

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

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

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/sendtx/")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo/api/v2/sendtx/");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /{apiKey}/api/v2/sendtx/
method: POST
operation:
  operationId: sendTransactionPost
  summary: Send Transaction (POST)
  description: |
    Broadcasts a signed raw Bitcoin transaction by sending hex bytes in the request body. The trailing slash on the path is mandatory; see the [Blockbook API reference](https://github.com/trezor/blockbook/blob/master/docs/api.md#send-transaction). Use this for larger payloads (request body limit 8 MiB). Returns the transaction ID on success.

    > **Heads up**: the POST variant currently returns `{ "error": "Parse error" }` (HTTP 400) > on the Alchemy proxy regardless of body format. Until that upstream issue is resolved, > prefer the GET variant above for hex payloads under the URL-length limit.
  tags:
    - UTXO API Endpoints
  parameters:
    - name: apiKey
      in: path
      required: true
      schema:
        type: string
        default: docs-demo
      description: For higher throughput, [create your own API key](https://dashboard.alchemy.com/signup)
  requestBody:
    required: true
    content:
      text/plain:
        schema:
          type: string
          description: Hex-encoded raw transaction bytes.
          example: 02000000000101662a2fc609ddb4ebf96113d237041d687c94494f44c10d8dc8e23d3774b5b70e0100000000fdffffff0298ab0200000000001976a914ecc999d554eaa3efa5e871c28f58b549c36ec51788ac64e196000000000016001496f152a0919487624bf4f13f46f0d20fa10d9acc0247304402202bb0591180cdbbe0f639af6eb21abdb993fc5a667b09e6392d5c11b025a9187102201ef2e84fc91a5d2c6fbbc9f943482d230256a3640f8ecb83c1f3f17242cf011001210314f03889e1667feb696ee280625943195189cfabe46d54204d987f631fe6892739220d00
  responses:
    '200':
      description: Transaction broadcast result.
      content:
        application/json:
          schema:
            type: object
            properties:
              result:
                type: string
                description: Transaction ID of the broadcast transaction.
          example:
            result: 8c1e3dec662d1f2a5e322ccef5eca263f98eb16723c6f990be0c88c1db113fb1
    '400':
      description: Malformed request.
      content:
        application/json:
          schema:
            type: object
            required:
              - error
            properties:
              error:
                type: string
                description: Human-readable error message.
          example:
            error: invalid request
```
