> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Transaction

> Use this endpoint to create a transaction. This endpoint accepts the optional `MX-SKIP-WEBHOOK` header. It is recommended that partners only send dates in one format, using either the `_on` or `_at` fields, but not both.

## Path Parameters

<ParamField path="user_id" required type="string" />

<ParamField path="member_id" required type="string" />

<ParamField path="account_id" required type="string" />

## Body Parameters

<ParamField body="amount" required type="decimal" />

<ParamField body="category_guid" type="string" />

<ParamField body="category" type="string" />

<ParamField body="check_image" type="string" />

<ParamField body="check_number" type="string" />

<ParamField body="currency_code" type="string" />

<ParamField body="description" required type="string" />

<ParamField body="id" required type="string" />

<ParamField body="is_international" type="string" />

<ParamField body="latitude" type="string" />

<ParamField body="localized_description" type="string" />

<ParamField body="localized_memo" type="string" />

<ParamField body="longitude" type="string" />

<ParamField body="memo" type="string" />

<ParamField body="merchant_category_code" type="string" />

<ParamField body="metadata" type="string" />

<ParamField body="posted_at" required type="string">
  One of either `posted_at` or `posted_on` is required.
</ParamField>

<ParamField body="posted_on" required type="string">
  One of either `posted_at` or `posted_on` is required.
</ParamField>

<ParamField body="status" required type="string" />

<ParamField body="transacted_at" required type="string">
  One of either `transacted_at` or `transacted_on` is required.
</ParamField>

<ParamField body="transacted_on" required type="string">
  One of either `transacted_at` or `transacted_on` is required.
</ParamField>

<ParamField body="type" required type="string" />

<RequestExample>
  ```shell Request theme={null}
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  import java.net.URL;
  import javax.net.ssl.HttpsURLConnection;
  import org.json.JSONObject;

  public class MDX_RealTime {
  	private String BaseUrl, ClientId, ApiKey;

  	public MDX_RealTime(String BaseUrl, String ClientId, String ApiKey) {
  		this.BaseUrl = BaseUrl;
  		this.ClientId = ClientId;
  		this.ApiKey = ApiKey;
  	}

  	public static void main(String[] args) throws Exception {
  		String base_url = "https://int-live.moneydesktop.com";
  		String client_id = ":client_id";
  		String api_key = ":api_key";

  		MDX_RealTime mdx = new MDX_RealTime(base_url, client_id, api_key);
  		
  		/// Setup Account Create json object
  		String user_id = "U-39XBF7";
  		String member_id = "M-39XBF7";
  		String account_id = "A-XA5Y4L";
  		String transaction_id = "T-3QP5X0";
  		JSONObject transaction = new JSONObject();
  		JSONObject fields = new JSONObject();
  		fields.put("id", "T-3QP5X0");
  		fields.put("amount", 8.20);
  		fields.put("description", "COSTCO GAS STATION #22299");
  		fields.put("status", "PENDING");
  		fields.put("type", "DEBIT");
  		fields.put("transacted_on", "2017-01-20");
  		transaction.put("transaction", fields);

  		mdx.CreateTransaction(user_id, member_id, account_id, transaction);
  	}

  	public void CreateTransaction(String user_id, String member_id, String account_id, JSONObject transaction) {
  		try {
  			String uri = BaseUrl + "/" + ClientId + "/users/" + user_id + "/members/" + member_id + "/accounts/" + account_id + "/transactions.json";
  			URL url = new URL(uri);
  			
  			HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
  			con.setRequestMethod("POST");
  			con.setRequestProperty("Accept", "application/vnd.moneydesktop.mdx.v5+json");
  			con.setRequestProperty("Content-Type", "application/vnd.moneydesktop.mdx.v5+json");
  			con.setRequestProperty("MD-API-KEY", ApiKey);
  			con.setDoOutput(true);

  			OutputStream out = con.getOutputStream();
  			out.write(transaction.toString().getBytes("UTF-8"));
  			out.close();

  			BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
  			String inputLine;
  			StringBuffer response = new StringBuffer();
  			while ((inputLine = in.readLine()) != null) {
  				response.append(inputLine);
  			}
  			in.close();
  			con.disconnect();

  			System.out.println(response.toString());
  		} catch (Exception e) {
  			System.out.println(e);
  		}
  	}
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "transaction": {
      "account_guid": "ACT-a341b026-635c-8318-002c-9f3a58b0eff8",
      "account_id": "A-XZ5Y4L",
      "amount": 8.2,
      "category": "GAS",
      "category_guid": "CAT-7829f71c-2e8c-afa5-2f55-fa3634b89874",
      "category_name": "Gas",
      "check_image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
      "check_number": "9543",
      "currency_code": null,
      "description": "Costco (Gas)",
      "guid": "TRN-cd2987fe-9afb-e912-a5e3-2eaabb866e43",
      "id": "T-3QP5X0",
      "is_international": false,
      "latitude": "40.429675",
      "localized_description": null,
      "localized_memo": null,
      "longitude": "-111.891982",
      "member_guid": "MBR-3e4f6897-06ae-e08a-29b2-27d62e574978",
      "member_id": "M-39XBF7",
      "memo": "POS Purchase",
      "merchant_category_code": null,
      "merchant_guid": "MCH-bcd4eed1-f341-b7bb-4cbd-e2a854205306",
      "merchant_location_guid": null,
      "metadata": null,
      "posted_at": 1382961600,
      "posted_on": "2013-10-28",
      "running_balance": 345.45,
      "status": "POSTED",
      "transacted_at": 1382961600,
      "transacted_on": "2013-10-28",
      "type": "DEBIT",
      "user_guid": "USR-fe9bb059-67c4-0e6b-e8cd-3fa00b2b5735",
      "user_id": "U-39XBF7"
    }
  }
  ```
</ResponseExample>
