# Get the current integration

Returns the integration that owns the API key, with its scopes and its product.

`GET /v1/me`

## Use cases

- Check that a new API key works.
- Show which integration and which key a program uses.
- Read the scopes of the integration before a call.

## Authentication

Send an API key. This endpoint requires no scope, so an integration without any scopes can call it. See [Authentication](../authentication/).

## Request

### Headers

| Header | Required | Description |
| --- | --- | --- |
| `Authorization` | Yes | The word `Bearer`, a space and the API key. |

## Response

The answer has the status 200.

| Field | Type | Description |
| --- | --- | --- |
| `org` | object | The organization that owns the integration. See [Org](#org). |
| `integration` | object | The integration that owns the API key. See [Integration](#integration). |
| `key` | object | The API key of the request. See [Key](#key). |
| `scopes` | array of strings | Every scope of the integration. A write scope adds the read scope of the same resource, so both are in the list. See [Scopes](../integrations-and-scopes/#scopes). |

### Org

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | The ID of the organization. |
| `name` | string | The name of the organization. |

### Integration

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | The ID of the integration. |
| `name` | string | The name of the integration. |
| `product_id` | string or null | The ID of the product that the integration is limited to. It is `null` when the integration can reach every product. See [Product](../integrations-and-scopes/#product). |

### Key

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | The ID of the key. |
| `name` | string | The name of the key. |
| `expires_at` | string or null | The time when the key expires. It is `null` when the key does not expire. |

## Errors

| Status | Reason | Description |
| --- | --- | --- |
| 401 | `An API key is required.` | The request has no `Authorization` header, the header is empty, or the header does not use the `Bearer` scheme. |
| 401 | `The API key is not valid.` | No integration has this key. |
| 401 | `The API key has expired.` | The expiry date of the key has passed. |
| 429 | `There are too many requests. Try again later.` | See [Rate limits](../#rate-limits). |

See [Errors](../#errors).

## Example

{{< tabs >}}
{{< tab name="curl" >}}
```bash
curl https://api.seatify.dev/v1/me \
  -H "Authorization: Bearer $SEATIFY_API_KEY"
```
{{< /tab >}}
{{< tab name="Swift" >}}
```swift
import Foundation

struct Me: Decodable {
    struct Org: Decodable {
        let id: String
        let name: String
    }

    struct Integration: Decodable {
        let id: String
        let name: String
        let productID: String?

        enum CodingKeys: String, CodingKey {
            case id, name
            case productID = "product_id"
        }
    }

    struct Key: Decodable {
        let id: String
        let name: String
        let expiresAt: String?

        enum CodingKeys: String, CodingKey {
            case id, name
            case expiresAt = "expires_at"
        }
    }

    let org: Org
    let integration: Integration
    let key: Key
    let scopes: [String]
}

var request = URLRequest(url: URL(string: "https://api.seatify.dev/v1/me")!)
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")

let (data, _) = try await URLSession.shared.data(for: request)
let me = try JSONDecoder().decode(Me.self, from: data)
```
{{< /tab >}}
{{< tab name="C#" >}}
```csharp
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json.Serialization;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);

var me = await client.GetFromJsonAsync<Me>("https://api.seatify.dev/v1/me");

record Me(Org Org, Integration Integration, Key Key, string[] Scopes);
record Org(string Id, string Name);
record Integration(string Id, string Name, [property: JsonPropertyName("product_id")] string? ProductId);
record Key(string Id, string Name, [property: JsonPropertyName("expires_at")] DateTimeOffset? ExpiresAt);
```
{{< /tab >}}
{{< tab name="Go" >}}
```go
req, err := http.NewRequest("GET", "https://api.seatify.dev/v1/me", nil)
if err != nil {
	return err
}
req.Header.Set("Authorization", "Bearer "+apiKey)

res, err := http.DefaultClient.Do(req)
if err != nil {
	return err
}
defer res.Body.Close()

var me struct {
	Org struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"org"`
	Integration struct {
		ID        string  `json:"id"`
		Name      string  `json:"name"`
		ProductID *string `json:"product_id"`
	} `json:"integration"`
	Key struct {
		ID        string     `json:"id"`
		Name      string     `json:"name"`
		ExpiresAt *time.Time `json:"expires_at"`
	} `json:"key"`
	Scopes []string `json:"scopes"`
}
err = json.NewDecoder(res.Body).Decode(&me)
```
{{< /tab >}}
{{< tab name="JavaScript" >}}
```javascript
const response = await fetch("https://api.seatify.dev/v1/me", {
  headers: { Authorization: `Bearer ${apiKey}` },
});
const me = await response.json();
```
{{< /tab >}}
{{< /tabs >}}

The answer:

```json
{
  "org": {
    "id": "<org id>",
    "name": "Northwind Software"
  },
  "integration": {
    "id": "<integration id>",
    "name": "Zapier",
    "product_id": "<product id>"
  },
  "key": {
    "id": "<key id>",
    "name": "production",
    "expires_at": null
  },
  "scopes": [
    "policies:read",
    "licenses:read",
    "licenses:write",
    "customers:read",
    "customers:write"
  ]
}
```

