# Organization ID

## Fetch User's Organizations ID

Retrieving the user's organization info is done through querying the user's information. One can query details inside the organization.

{% hint style="info" %}
Note that you can fetch more than just the organization ID, all depending on what you're filling in the query.
{% endhint %}

```graphql
query User($where: UserWhereUniqueInput!) {
  user(where: $where) {
    organizations {
      id
      name
    }
  }
}
```

### **Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

### **Body (**<mark style="color:orange;">UserWhereUniqueInput</mark> object)

| Name                                 | Type   | Description                                                                            |
| ------------------------------------ | ------ | -------------------------------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | string | <p>ID of the logged in user. <br>See <a href="broken-reference">Authorization</a>.</p> |

[Example body:](#user-content-fn-1)[^1]

```json
{
  "where": {
    "id": "userId123"
  }
}
```

### **Response**

Returned values:

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| id   | string | Organization ID   |
| name | string | Organization name |

{% tabs %}
{% tab title="🟢 Success" %}

```json
{
  "data": {
    "user": {
      "organizations": [
        {
          "id": "clilpvru98723678mwie82oihn9",
          "name": "Crypto Org 1"
        }
      ]
    }
  }
}
```

{% endtab %}

{% tab title="🔴 Failure" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

### Try it out!

{% embed url="<https://studio.apollographql.com/sandbox/explorer?endpoint=https://api.inabit.app/graphql&explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAPJ4DmAhkgJYBelKNESAFACQDuAFvguqQrV6jZkgDqvPAgCqtHAgCSSAA4wUAQgCURYAB0kelBCG0GTFqx58BXKQh37DKIwjiUaAGwNGjK7iwIAMIQMKiEuj4u0f6BIWAIUUYAvkkosUiJzkZQoeHETr7RSJSIaanZKADOKNIILpVQNCgEaTWMCJGVRiVllRVFdDQq8VlFsHjSSFAFaTkQCeVRFckgyUA>" fullWidth="false" %}

[^1]:
