> For the complete documentation index, see [llms.txt](https://docs.trustlesswork.com/trustless-work/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trustlesswork.com/trustless-work/v2-en/api-rest/stellar/send-transaction.md).

# Send Transaction

{% hint style="info" %}
Use this endpoint after you sign an unsigned XDR returned by another endpoint.
{% endhint %}

### What it does

This endpoint submits a signed Stellar transaction to the network.

Typical flow:

1. Call an endpoint that returns `unsignedTransaction`.
2. Sign that XDR with the user wallet.
3. Submit the signed XDR here.

### Headers

<table><thead><tr><th width="366">Name</th><th>Value</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td></tr><tr><td>x-api-key</td><td><code>&#x3C;token></code></td></tr></tbody></table>

### API reference

## Submit a client-signed XDR to the Stellar network

> Forwards the signed transaction to Horizon, then polls the Soroban RPC to enrich the response with on-chain metadata. The response has three mutually-exclusive shapes:\
> \
> &#x20; \- Plain contract call (fund, release, approve, dispute, etc.): \`{ txHash, ledger, code: "STELLAR\_TX\_SUBMITTED", message }\`.\
> &#x20; \- Factory deploy (success): \`{ txHash, ledger, contractId, escrow }\` with the freshly-indexed snapshot — no \`code\`/\`message\`.\
> &#x20; \- Factory deploy (indexer lagging): \`{ txHash, ledger, code: "STELLAR\_TX\_SUBMITTED\_INDEXER\_LAGGING", message }\` — the tx is in the ledger; retry \`getTransaction(txHash)\` shortly to recover the contract address.\
> \
> Clients should branch on \`code\` when present, otherwise on the existence of \`contractId\`. The \`code\` is stable; the \`message\` is free text and subject to change.

```json
{"openapi":"3.0.0","info":{"title":"👋🏼 Trustless Work Core API — All Endpoints (Unified)","version":"1.0"},"security":[{}],"paths":{"/stellar/send-transaction":{"post":{"description":"Forwards the signed transaction to Horizon, then polls the Soroban RPC to enrich the response with on-chain metadata. The response has three mutually-exclusive shapes:\n\n  - Plain contract call (fund, release, approve, dispute, etc.): `{ txHash, ledger, code: \"STELLAR_TX_SUBMITTED\", message }`.\n  - Factory deploy (success): `{ txHash, ledger, contractId, escrow }` with the freshly-indexed snapshot — no `code`/`message`.\n  - Factory deploy (indexer lagging): `{ txHash, ledger, code: \"STELLAR_TX_SUBMITTED_INDEXER_LAGGING\", message }` — the tx is in the ledger; retry `getTransaction(txHash)` shortly to recover the contract address.\n\nClients should branch on `code` when present, otherwise on the existence of `contractId`. The `code` is stable; the `message` is free text and subject to change.","operationId":"SendTransactionController_submit","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendTransactionDto"}}}},"responses":{"200":{"description":"Transaction accepted by the network. Inspect `code` (plain or indexer-lagging) or `contractId` / `escrow` (factory deploy success) to know which variant you received.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendTransactionResponse"}}}},"400":{"description":"Request body or query params fail schema validation (wrong type, missing required field, unknown property).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProblemDetailsResponseDto"}}}},"401":{"description":"Missing, malformed, expired, revoked or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProblemDetailsResponseDto"}}}},"403":{"description":"API key is valid but does not have the role required for this operation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProblemDetailsResponseDto"}}}},"422":{"description":"Payload is well-formed but a business rule rejects it (e.g. amount out of range, role not allowed for this user).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProblemDetailsResponseDto"}}}},"500":{"description":"Unexpected server-side failure. Use the `traceId` to look up the incident in server logs or contact support.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProblemDetailsResponseDto"}}}}},"summary":"Submit a client-signed XDR to the Stellar network","tags":["Stellar"]}}},"components":{"schemas":{"SendTransactionDto":{"type":"object","properties":{"signedXdr":{"type":"string","description":"Base64-encoded signed Soroban / Stellar XDR. Produced by the client wallet after signing the unsigned XDR returned by an escrow build endpoint."}},"required":["signedXdr"]},"SendTransactionResponse":{"type":"object","properties":{"txHash":{"type":"string","description":"SHA-256 hash of the submitted transaction (hex)."},"ledger":{"type":"number","description":"Ledger sequence number where the transaction was included."},"contractId":{"type":"string","description":"Address of the freshly-deployed escrow contract. Present only when the transaction was a factory deploy and the network confirmed it before the indexer timeout."},"escrow":{"type":"object","description":"Initial snapshot of the deployed escrow, reconstructed from the factory return value. Shape depends on the escrow kind that was deployed (single-release v1/v2, multi-release v1/v2).","additionalProperties":true},"code":{"type":"string","description":"Stable, machine-readable result code. Present on plain submits and on factory deploys whose Soroban return value did not arrive in time. Absent on successful factory deploys (the caller branches on `contractId` / `escrow` instead).","enum":["STELLAR_TX_SUBMITTED","STELLAR_TX_SUBMITTED_INDEXER_LAGGING"]},"message":{"type":"string","description":"Human-readable companion to `code`. Free text — subject to change. Clients that need control-flow decisions must read `code`, not this."}},"required":["txHash","ledger"]},"ProblemDetailsResponseDto":{"type":"object","properties":{"type":{"type":"string","description":"Stable URI identifying the error type. Hash-link points to the docs."},"title":{"type":"string","description":"Short human-readable summary of the problem."},"status":{"type":"number","description":"HTTP status code, repeated here for typed clients."},"code":{"type":"string","description":"Machine-readable error code. Stable across versions; safe to switch on."},"detail":{"type":"string","description":"Human-readable explanation specific to this occurrence."},"instance":{"type":"string","description":"URI of the request that triggered the error."},"traceId":{"type":"string","description":"Correlation id propagated from the `X-Trace-Id` header (or generated). Use it when contacting support to reference a specific request."},"extensions":{"type":"object","description":"Optional structured context. Shape depends on the error code; documented per-endpoint when relevant.","additionalProperties":true}},"required":["type","title","status","code","detail"]}}}}
```

### Response

This endpoint returns the submitted transaction result from the Stellar network.

### Example

{% code title="send-transaction.ts" lineNumbers="true" %}

```typescript
import axios from "axios";

const http = axios.create({
  baseURL: "https://dev.api.trustlesswork.com",
  timeout: 10000,
  headers: {
    "Content-Type": "application/json",
    "x-api-key": your_api_key,
  },
});

export const useExample = async () => {
  // Get the signer address
  const { address } = await kit.getAddress();

  const response = await http.post("/any-endpoint", {
    // body requested for the endpoint
  });

  // Get the unsigned transaction XDR
  const { unsignedTransaction } = response.data;

  // Sign the transaction with the wallet
  const { signedTxXdr } = await signTransaction(unsignedTransaction, {
    address,
    networkPassphrase: WalletNetwork.TESTNET,
  });

  // Submit the signed transaction
  const tx = await http.post("/stellar/send-transaction", {
    signedXdr: signedTxXdr,
  });

  return tx.data;
};
```

{% endcode %}

### Notes

* Pass the signed XDR in the `signedXdr` field.
* Use the same network passphrase used to build the transaction.
* This step usually comes right after a create, update, fund, or release call.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.trustlesswork.com/trustless-work/v2-en/api-rest/stellar/send-transaction.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
