# Method: externaltransactions.createexternaltransaction

- [HTTP request](https://developers.google.com/android-publisher/api-ref/rest/v3/externaltransactions/createexternaltransaction#body.HTTP_TEMPLATE)
- [Path parameters](https://developers.google.com/android-publisher/api-ref/rest/v3/externaltransactions/createexternaltransaction#body.PATH_PARAMETERS)
- [Query parameters](https://developers.google.com/android-publisher/api-ref/rest/v3/externaltransactions/createexternaltransaction#body.QUERY_PARAMETERS)
- [Request body](https://developers.google.com/android-publisher/api-ref/rest/v3/externaltransactions/createexternaltransaction#body.request_body)
- [Response body](https://developers.google.com/android-publisher/api-ref/rest/v3/externaltransactions/createexternaltransaction#body.response_body)
- [Authorization scopes](https://developers.google.com/android-publisher/api-ref/rest/v3/externaltransactions/createexternaltransaction#body.aspect)
- [Try it!](https://developers.google.com/android-publisher/api-ref/rest/v3/externaltransactions/createexternaltransaction#try-it)

Creates a new external transaction.

### HTTP request

`POST https://androidpublisher.googleapis.com/androidpublisher/v3/{parent=applications/*}/externalTransactions`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The parent resource where this external transaction will be created. Format: applications/{packageName} |

### Query parameters

| Parameters ||
|---|---|
| `externalTransactionId` | `string` Required. The id to use for the external transaction. Must be unique across all other transactions for the app. This value should be 1-63 characters and valid characters are /a-zA-Z0-9_-/. Do not use this field to store any Personally Identifiable Information (PII) such as emails. Attempting to store PII in this field may result in requests being blocked. |

### Request body

The request body contains an instance of `https://developers.google.com/android-publisher/api-ref/rest/v3/externaltransactions#ExternalTransaction`.

### Response body

If successful, the response body contains a newly created instance of `https://developers.google.com/android-publisher/api-ref/rest/v3/externaltransactions#ExternalTransaction`.

### Sample

The following is a sample request:

```json
curl \
  -X POST \
  'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.app/externalTransactions?externalTransactionId=exampleExternalTransactionId' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  -H 'Content-Type: application/json' \
  -d '{ \
    "originalPreTaxAmount": { \
      "currency": "USD", \
      "priceMicros": "1000000" \
    }, \
    "originalTaxAmount": { \
      "currency": "USD", \
      "priceMicros": "100000" \
    }, \
    "transactionTime": "2023-05-05T12:00:00Z", \
    "oneTimeTransaction": { \
      "externalTransactionToken": "token-123" \
    }, \
    "userTaxAddress": { \
      "regionCode": "US" \
    } \
  }'
```

The following is a sample response:

```json
{
  "createTime": "2023-04-20T14:23:18.121Z",
  "currentPreTaxAmount": {
    "currency": "USD",
    "priceMicros": "12000000"
  },
  "currentTaxAmount": {
    "currency": "USD",
    "priceMicros": "1200000"
  },
  "externalTransactionId": "ext-trans-id-1234",
  "oneTimeTransaction": {
    "externalTransactionToken": "one-time-token-abc"
  },
  "originalPreTaxAmount": {
    "currency": "USD",
    "priceMicros": "15000000"
  },
  "originalTaxAmount": {
    "currency": "USD",
    "priceMicros": "1500000"
  },
  "packageName": "com.example.app",
  "recurringTransaction": {
    "externalSubscription": {
      "subscriptionType": "RECURRING"
    },
    "externalTransactionToken": "recurring-token-xyz",
    "initialExternalTransactionId": "ext-trans-id-5678",
    "otherRecurringProduct": {}
  },
  "testPurchase": {},
  "transactionProgramCode": 11,
  "transactionState": "TRANSACTION_REPORTED",
  "transactionTime": "2023-04-20T14:20:00.000Z",
  "userTaxAddress": {
    "regionCode": "US"
  }
}
```

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/androidpublisher`