# Warehouse

### Organization warehouse

The organization warehouse is where an organization can deposit their credits and give apps access to the warehouse inventory where they can transfer them without asking for permission to do so each time.&#x20;

But to move credits from the warehouse they first need to be put into the reservation queue, where they are reserved for the app that put them in the queue. This is so that the app can verify off platform data / actions before finalizing a transfer / retirement action. This can be very handy for marketplaces that do not wish to hold the credits themselves and instead use the warehouse system to reserve and transfer the credits when an actual buyer / retiree has been found.

#### list all credits in the warehouse inventory

{% openapi src="<https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media&token=b0070a9e-b5c0-4246-9200-1241aa683103>" path="/organizations/{id}/warehouse/inventory" method="get" %}
[openapi.yaml](https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media\&token=b0070a9e-b5c0-4246-9200-1241aa683103)
{% endopenapi %}

This returns a list of all the credits in the organization's warehouse. Ids for the projects that issued those credits are also in place so using this endpoint in conjunction with the [projects](https://documentation.carbonregistry.com/documentation/carbonregistry.com/api/endpoints/projects#projects) or [project](https://documentation.carbonregistry.com/documentation/carbonregistry.com/api/endpoints/projects#projects-projectid) endpoints is handy.

Callable by any access token with permissions "[organization\_warehouse:read](https://documentation.carbonregistry.com/documentation/carbonregistry.com/apps/creating-icr-apps/registering-an-icr-app/permissions#organization_warehouse)".

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X 'GET' \
  'https://api.carbonregistry.com/organizations/{ORG_ID}/warehouse/inventory' \
  -H 'accept: application/json' \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -H 'x-icr-api-version: 2023-06-16'
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}

#### inventory reservations

{% openapi src="<https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media&token=b0070a9e-b5c0-4246-9200-1241aa683103>" path="/organizations/{id}/warehouse/inventory/reservations" method="get" %}
[openapi.yaml](https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media\&token=b0070a9e-b5c0-4246-9200-1241aa683103)
{% endopenapi %}

Returns a paginated list of all reservations, and the state of those reservations, made against the organization's warehouse.

Callable by any access token with permissions "[organization\_warehouse:read](https://documentation.carbonregistry.com/documentation/carbonregistry.com/apps/creating-icr-apps/registering-an-icr-app/permissions#organization_warehouse)".

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X 'GET' \
  'https://api.carbonregistry.com/organizations/{ORG_ID}/warehouse/inventory/reservations' \
  -H 'accept: application/json' \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -H 'x-icr-api-version: 2023-06-16'
```

{% endtab %}

{% tab title="Typescript" %}

{% endtab %}
{% endtabs %}

#### reserve credits

{% openapi src="<https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media&token=b0070a9e-b5c0-4246-9200-1241aa683103>" path="/organizations/{id}/warehouse/inventory/reservations" method="post" %}
[openapi.yaml](https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media\&token=b0070a9e-b5c0-4246-9200-1241aa683103)
{% endopenapi %}

Reserving credits from a warehouse for later transfer. They are reserved for up to 10 minutes before they are moved back into the warehouse.

Callable by any access token with permissions "[organization\_warehouse:write](https://documentation.carbonregistry.com/documentation/carbonregistry.com/apps/creating-icr-apps/registering-an-icr-app/permissions#organization_warehouse)".

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X 'POST' \
  'https://api.carbonregistry.com/organizations/{ORG_ID}/warehouse/inventory/reservations' \
  -H 'accept: application/json' \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -H 'x-icr-api-version: 2023-06-16' \
  -H 'Content-Type: application/json' \
  -d '{
  "amount": 10,
  "creditId": "exPost-2-0x51298f2f1142ecb129a2db5e6afd24f34f2e53f1"
}'
```

{% endtab %}

{% tab title="Typescript" %}

{% endtab %}
{% endtabs %}

#### specific reservation&#x20;

{% openapi src="<https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media&token=b0070a9e-b5c0-4246-9200-1241aa683103>" path="/organizations/{id}/warehouse/inventory/reservations/{reservationId}" method="get" %}
[openapi.yaml](https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media\&token=b0070a9e-b5c0-4246-9200-1241aa683103)
{% endopenapi %}

Gets a specific reservation made.

Callable by any access token with permissions "[organization\_warehouse:read](https://documentation.carbonregistry.com/documentation/carbonregistry.com/apps/creating-icr-apps/registering-an-icr-app/permissions#organization_warehouse)".

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X 'GET' \
  'https://api.carbonregistry.com/organizations/{ORG_ID}/warehouse/inventory/reservations/{RESERVATION_ID}' \
  -H 'accept: application/json' \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -H 'x-icr-api-version: 2023-06-16'
```

{% endtab %}

{% tab title="Typescript" %}

{% endtab %}
{% endtabs %}

#### cancel specific reservation

{% openapi src="<https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media&token=b0070a9e-b5c0-4246-9200-1241aa683103>" path="/organizations/{id}/warehouse/inventory/reservations/{reservationId}" method="delete" %}
[openapi.yaml](https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media\&token=b0070a9e-b5c0-4246-9200-1241aa683103)
{% endopenapi %}

Cancels an outstanding reservation your app made.

Callable by any access token with permissions "[organization\_warehouse:write](https://documentation.carbonregistry.com/documentation/carbonregistry.com/apps/creating-icr-apps/registering-an-icr-app/permissions#organization_warehouse)".

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X 'DELETE' \
  'https://api.carbonregistry.com/organizations/{ORG_ID}/warehouse/inventory/reservations/{RESERVATION_ID}' \
  -H 'accept: application/json' \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -H 'x-icr-api-version: 2023-06-16'
```

{% endtab %}

{% tab title="Typescript" %}

{% endtab %}
{% endtabs %}

#### finish outstanding reservation

{% openapi src="<https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media&token=b0070a9e-b5c0-4246-9200-1241aa683103>" path="/organizations/{id}/warehouse/inventory/reservations/{reservationId}/{action}" method="post" %}
[openapi.yaml](https://2441265052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIdoGcZZdvap67xjb5h1%2Fuploads%2Fmabe2nfB82a3vZ8qM4e9%2Fopenapi.yaml?alt=media\&token=b0070a9e-b5c0-4246-9200-1241aa683103)
{% endopenapi %}

This can only be called withing 10minutes from the creation of the reservation.

Callable by any access token with permissions "[organization\_warehouse:write](https://documentation.carbonregistry.com/documentation/carbonregistry.com/apps/creating-icr-apps/registering-an-icr-app/permissions#organization_warehouse)".

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X 'POST' \
  'https://api.carbonregistry.com/organizations/{ORG_ID}/warehouse/inventory/reservations/{RESERVATION_ID}/{ACTION}' \
  -H 'accept: application/json' \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
  -H 'x-icr-api-version: 2023-06-16' \
  -H 'Content-Type: application/json' \
  -d '{
  "receiverId": "123e4567-e89b-12d3-a456-426614174000",
  "receiverAddress": "0x51298f2f1142ecb129a2db5e6afd24f34f2e53f1",
  "transferComment": "This is a comment",
  "retirementData": {
    "reason": "Retirement reason",
    "beneficiaryName": "John Doe",
    "comment": "This is a comment"
  }
}'
```

{% endtab %}

{% tab title="Typescript" %}

{% endtab %}
{% endtabs %}
