Insurance

Shipment can be insured. We care about charging money from client’s balance to pay for insurance.

Insurance balance

Each insurance-related view will contain current_insurance_balance in response body. This field contains current insurance balance of the organization.

Insurance transactions

Insurance transactions shows charging or spending of insurance balance. They can be related to orders or boxes or they can refill insurance_balance with some amount of money charged from card.

Voiding of insurance transactions

If transaction was made by error, it can be voided. Transaction will be marked as void and new transaction with refilling insurance balance with amount of this one will be created.

Get list of insurance transactions

  • insurance_balance shows actual insurance balance of organization.

GET /orgs/{org_pk}/insurance/

Example request:

curl -iL --request GET "https://www.readycloud.com/api/v2/orgs/1/insurance/?bearer_token=4ef5b29b1f4f35c383bebfccf4bf4d01"

Response 200 (application/json):

{
  "count": 3,
  "next": null,
  "previous": null,
  "current_insurance_balance": "9991.00 USD",
  "results": [
    {
      "url": "/api/v2/orgs/1/insurance/1/",
      "amount": "9999.00 USD",
      "transaction_type": "refill",
      "created_at": "2017-11-09T11:19:46Z",
      "voided_by": null,
      "stripe_charge_id": "id_123",
      "void_of": null,
      "order": null,
      "box": null,
      "last_transaction": null,
      "balance": "9999.00 USD"
    },
    {
      "url": "/api/v2/orgs/1/insurance/2/",
      "amount": "-3.00 USD",
      "transaction_type": "charge",
      "created_at": "2017-11-09T11:19:46Z",
      "voided_by": null,
      "stripe_charge_id": null,
      "void_of": null,
      "order": null,
      "box": "/api/v2/orgs/1/orders/1/boxes/1/",
      "last_transaction": "/api/v2/orgs/1/insurance/1/",
      "balance": "9996.00 USD"
    },
    {
      "url": "/api/v2/orgs/1/insurance/3/",
      "amount": "-5.00 USD",
      "transaction_type": "charge",
      "created_at": "2017-11-09T11:19:46Z",
      "voided_by": null,
      "stripe_charge_id": null,
      "void_of": null,
      "order": "/api/v2/orgs/1/orders/1/",
      "box": null,
      "last_transaction": "/api/v2/orgs/1/insurance/2/",
      "balance": "9991.00 USD"
    }
  ]
}

Refill insurance balance.

Amount will be charged automatically from organization’s bank card and insurance_balance will be increased.

POST /orgs/{org_pk}/insurance/

  • Attributes:
    • amount (money, required) - amount of money to charge from card to increase insurance balance
    • transaction_type (string, required) - should be refill to refill insurance balance
    • last_transaction (url, required) - url of last the transaction of the organization

Example request:

curl -iL --request POST -H "Content-Type: application/json" --upload-file data.json "https://www.readycloud.com/api/v2/orgs/1/insurance/?bearer_token=4ef5b29b1f4f35c383bebfccf4bf4d01"

data.json:

{
  "transaction_type": "refill",
  "amount": "13 USD",
  "last_transaction": "/api/v2/orgs/1/insurance/3/"
}

Response 201 (application/json):

{
  "stripe_charge_id": "stripe_charge_id",
  "void_of": null,
  "order": null,
  "box": null,
  "url": "/api/v2/orgs/1/insurance/4/",
  "amount": "13.00 USD",
  "created_at": "2017-11-09T11:19:46Z",
  "voided_by": null,
  "transaction_type": "refill",
  "current_insurance_balance": "10004.00 USD",
  "last_transaction": "/api/v2/orgs/1/insurance/3/",
  "balance": "10004.00 USD"
}

GET

Retrieve details of specific insurance_transaction

GET /orgs/{org_pk}/insurance/{insurance_transaction_pk}/

Example request:

curl -iL --request GET "https://www.readycloud.com/api/v2/orgs/1/insurance/1/?bearer_token=4ef5b29b1f4f35c383bebfccf4bf4d01"

Response 200 (application/json):

{
  "current_insurance_balance": "9991.00 USD",
  "stripe_charge_id": "id_123",
  "void_of": null,
  "order": null,
  "box": null,
  "url": "/api/v2/orgs/1/insurance/1/",
  "amount": "9999.00 USD",
  "created_at": "2017-11-09T11:19:46Z",
  "voided_by": null,
  "transaction_type": "refill",
  "last_transaction": null,
  "balance": "9999.00 USD"
}

PATCH

Update specific insurance_transaction. Only void field can be updated. This will void the transaction.

PATCH /orgs/{org_pk}/insurance/{insurance_transaction_pk}/

Example request:

curl -iL --request PATCH -H "Content-Type: application/json" --upload-file data.json "https://www.readycloud.com/api/v2/orgs/1/insurance/1/?bearer_token=4ef5b29b1f4f35c383bebfccf4bf4d01"

data.json:

{
  "void": true
}

Response 200 (application/json):

{
  "stripe_charge_id": null,
  "void_of": null,
  "order": null,
  "last_transaction": "/api/v2/orgs/1/insurance/1/",
  "balance": "9996.00 USD",
  "box": "/api/v2/orgs/1/orders/1/boxes/1/",
  "url": "/api/v2/orgs/1/insurance/2/",
  "amount": "-3.00 USD",
  "created_at": "2017-11-09T11:19:46Z",
  "voided_by": "/api/v2/orgs/1/insurance/4/",
  "transaction_type": "charge",
  "current_insurance_balance": "9994.00 USD"
}

DELETE

Mark specific insurance_transaction as void (equal to patch it with void=True)

DELETE /orgs/{org_pk}/insurance/{insurance_transaction_pk}/

Response 204 (application/json)

Order insurance

GET

List of insurance transactions related to order

GET /orgs/{org_pk}/orders/{order_pk}/insurance/

Example request:

curl -iL --request GET "https://www.readycloud.com/api/v2/orgs/1/orders/1/insurance/?bearer_token=4ef5b29b1f4f35c383bebfccf4bf4d01"

Response 200 (application/json):

{
  "count": 1,
  "next": null,
  "previous": null,
  "current_insurance_balance": "9991.00 USD",
  "results": [
    {
      "url": "/api/v2/orgs/1/insurance/3/",
      "amount": "-5.00 USD",
      "created_at": "2017-11-09T11:19:46Z",
      "voided_by": null,
      "transaction_type": "charge",
      "last_transaction": "/api/v2/orgs/1/insurance/2/",
      "balance": "9991.00 USD"
    }
  ]
}

Insurance of order

POST /orgs/{org_pk}/orders/{order_pk}/insurance/

  • Attributes:
    • amount (money, required) - amount of money to charge from insurance balance to pay for order’s insurance
    • last_transaction (url, required) - url of last the transaction of the organization

Example request:

curl -iL --request POST -H "Content-Type: application/json" --upload-file data.json "https://www.readycloud.com/api/v2/orgs/1/orders/1/insurance/?bearer_token=4ef5b29b1f4f35c383bebfccf4bf4d01"

data.json:

{
  "amount": "13 USD",
  "last_transaction": "/api/v2/orgs/1/insurance/3/"
}

Response 201 (application/json):

{
  "url": "/api/v2/orgs/1/insurance/4/",
  "amount": "-13.00 USD",
  "created_at": "2017-11-09T11:19:46Z",
  "voided_by": null,
  "transaction_type": "charge",
  "current_insurance_balance": "9978.00 USD",
  "last_transaction": "/api/v2/orgs/1/insurance/3/",
  "balance": "9978.00 USD"
}

Box insurance

GET

List of insurance transactions related to box

GET /orgs/{org_pk}/orders/{order_pk}/boxes/{box_pk}/insurance/

Example request:

curl -iL --request GET "https://www.readycloud.com/api/v2/orgs/1/orders/1/insurance/?bearer_token=4ef5b29b1f4f35c383bebfccf4bf4d01"

Response 200 (application/json):

{
  "count": 1,
  "next": null,
  "previous": null,
  "current_insurance_balance": "9991.00 USD",
  "results": [
    {
      "url": "/api/v2/orgs/1/insurance/2/",
      "amount": "-3.00 USD",
      "created_at": "2017-11-09T11:19:46Z",
      "voided_by": null,
      "transaction_type": "charge",
      "last_transaction": "/api/v2/orgs/1/insurance/1/",
      "balance": "9996.00 USD"
    }
  ]
}

Insurance of box

POST /orgs/{org_pk}/orders/{order_pk}/boxes/{box_pk}/insurance/

  • Attributes:
    • amount (money, required) - amount of money to charge from insurance balance to pay for box’s insurance
    • last_transaction (url, required) - url of last the transaction of the organization

Example request:

curl -iL --request POST -H "Content-Type: application/json" --upload-file data.json "https://www.readycloud.com/api/v2/orgs/1/orders/1/boxes/1/insurance/?bearer_token=4ef5b29b1f4f35c383bebfccf4bf4d01"

data.json:

{
  "amount": "13 USD",
  "last_transaction": "/api/v2/orgs/1/insurance/3/"
}

Response 201 (application/json):

{
  "current_insurance_balance": "9978.00 USD",
  "url": "/api/v2/orgs/1/insurance/4/",
  "amount": "-13.00 USD",
  "created_at": "2017-11-09T11:19:46Z",
  "voided_by": null,
  "transaction_type": "charge",
  "last_transaction": "/api/v2/orgs/1/insurance/3/",
  "balance": "9978.00 USD"
}