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

# Create a transaction

> Create a transaction using the reward transaction authentication token from the previous step.

<Note>The `x-api-key` header value to be used on this API is a **user-based access token**.</Note>

<ParamField body="reward_authentication_token" type="string" required>
  The token received from the [authenticate reward transaction](/api-reference/endpoint/transactions/authenticate) API call.
</ParamField>

### Return values

<ResponseField name="reward_transactions" type="array">
  An array of reward transaction objects created with this transaction

  <Expandable title="items" defaultOpen="true">
    A reward transaction object property

    <Expandable title="properties" defaultOpen="true">
      <ResponseField name="id" type="integer">Benji Platform reward transaction identifier</ResponseField>
      <ResponseField name="partner_id" type="integer">The ID of the partner associated with this transaction in the Benji Platform</ResponseField>
      <ResponseField name="campaign_id" type="integer">The ID of the campaign triggered for this transaction in the Benji Platform</ResponseField>
      <ResponseField name="user_id" type="integer">The ID of the user associated with the transaction in the Benji Platform</ResponseField>
      <ResponseField name="merchant_id" type="integer">The ID of the merchant partner associated with this campaign in the Benji Platform</ResponseField>
      <ResponseField name="transaction_amount" type="integer">The total dollar amount of the transaction</ResponseField>
      <ResponseField name="reward_amount" type="integer">The total amount of rewards earned or redeemed on this transaction</ResponseField>
      <ResponseField name="external_order_id" type="string">The external reference of the order on the merchant partner system</ResponseField>

      <ResponseField name="transaction_type" type="integer">
        Integer representing an enum of one of the following transaction type values:

        <Expandable title="possible transaction type values" type="enum">
          * **EARN (1)** : Indicating an earn transaction type <br />
          * **REDEEM (2)** : Indicating a redeem transaction type  <br />
        </Expandable>
      </ResponseField>

      <ResponseField name="status" type="integer">
        Integer representing an enum of one of the following transaction status values:

        <Expandable title="possible transaction status values" type="enum">
          * **PENDING (1)** : Indicating a transaction that is pending and has not been confirmed by the partner yet <br />
          * **CONFIRMED (2)** : Indicating a transaction that has been confirmed by the partner  <br />
          * **FAILED (3)** : Indicating a transaction that has been rejected by the partner  <br />
        </Expandable>
      </ResponseField>

      <ResponseField name="error_reason" type="string">If status is FAILED, the reason why this transaction was rejected</ResponseField>
      <ResponseField name="last_update_date" type="datetime">Datetime indicating the last status change. For instance, if the status is CONFIRMED, this date will indicate when the transaction was confirmed</ResponseField>
      <ResponseField name="created_date" type="datetime">The transaction date</ResponseField>
    </Expandable>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 200 theme={null}
  {
      "code": "ok",
      "data": {
          "reward_transactions": [{
              "created_date": "2024-08-23T19:55:12.015047+00:00",
              "last_updated_date": "2024-08-23T19:57:12.015047+00:00",
              "status": 2,
              "external_order_id": "5856681787572",
              "id": 1,
              "merchant_id": 1,
              "partner_id": 1,
              "campaign_id": 1,
              "reward_amount": 266,
              "transaction_amount": 885.95,
              "transaction_type": 1,
              "user_id": 1
          }]
      }
  }
  ```

  ```json 400 theme={null}
  {
    "error": "invalid_token",
    "message": "Invalid token"
  }
  ```

  ```json 400 theme={null}
  {
    "error": "transaction_already_exists",
    "message": "The transaction has already been created"
  }
  ```

  ```json 401 theme={null}
  {
    "error": "unauthorized_request",
    "message": "Token is not authorized to make this request"
  }
  ```
</ResponseExample>

<Tip>Make sure to store the returned reward transaction ID. You can use this ID to get the status of the reward transaction when receiving reward\_transaction\_update webhooks.</Tip>
<Warning>The transaction authentication token is valid for 10 minutes.</Warning>
