Skip to main content
POST
/
api
/
v2
/
platform
/
store_credits
Create a Store Credit
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    store_credit: {
      user_id: '2',
      category_id: '4',
      created_by_id: '5',
      amount: 25,
      currency: 'USD',
      type_id: '1',
      store_id: '2',
      amount_used: 10,
      memo: 'This credit was given as a refund',
      amount_authorized: 15.5,
      originator_id: '3',
      originator_type: 'Refund',
      public_metadata: {},
      private_metadata: {}
    }
  })
};

fetch('http://{defaultHost}/api/v2/platform/store_credits', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "data": {
    "id": "6",
    "type": "store_credit",
    "attributes": {
      "amount": "150.0",
      "amount_used": "0.0",
      "memo": null,
      "deleted_at": null,
      "currency": "USD",
      "amount_authorized": "0.0",
      "originator_type": null,
      "created_at": "2022-11-08T19:35:39.272Z",
      "updated_at": "2022-11-08T19:35:39.272Z",
      "public_metadata": {},
      "private_metadata": {},
      "display_amount": "$150.00",
      "display_amount_used": "$0.00"
    },
    "relationships": {
      "user": {
        "data": {
          "id": "113",
          "type": "user"
        }
      },
      "created_by": {
        "data": {
          "id": "114",
          "type": "user"
        }
      },
      "store_credit_category": {
        "data": {
          "id": "18",
          "type": "store_credit_category"
        }
      },
      "store_credit_type": {
        "data": {
          "id": "18",
          "type": "store_credit_type"
        }
      },
      "store_credit_events": {
        "data": [
          {
            "id": "7",
            "type": "store_credit_event"
          }
        ]
      }
    }
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

include
string

Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes

Body

application/json
store_credit
object
required

Response

Record created

data
object
required