# Workspace

Check what a key can do, list the websites it covers, and read the semantic layer: every metric and dimension, plus the outcomes this particular workspace can be measured by.

Source: https://sourceloop.ai/help/api/workspace/

---

| Endpoint | Method | Path | Permission |
| --- | --- | --- | --- |
| Get key info | GET | `/v1/me` | any key |
| List outcomes | GET | `/v1/outcomes` | `metrics:read` |
| Get schema | GET | `/v1/schema` | any key |
| List websites | GET | `/v1/websites` | any key |

Base URL: `https://app.sourceloop.ai/api/v1`

## Get key info

`GET /v1/me`

What this key is and what it can do

Requires: any valid API key.

The first call to make. Returns the scopes, plan and websites this key reaches.

### Responses

- `200` Key identity
- `403` Something was wrong with the request or the credential.
- `429` Too many requests for this workspace in the current minute (`rate-limit-exceeded`), the monthly allowance used (`quota-exceeded`), or too many analytics queries running at once (`too-many-concurrent`). Wait Retry-After seconds and repeat the request unchanged.

### Example (cURL)

```bash
curl -s -X GET "https://app.sourceloop.ai/api/v1/me" \
  -H "Authorization: Bearer $SOURCELOOP_API_KEY"
```

### Example (Node)

```javascript
const res = await fetch(
  "https://app.sourceloop.ai/api/v1/me",
  {
    method: "GET",
    headers: {
      Authorization: `Bearer ${process.env.SOURCELOOP_API_KEY}`,
    },
  },
);

const data = await res.json();
```

### Example (Python)

```python
import os, requests

res = requests.get(
    "https://app.sourceloop.ai/api/v1/me",
    headers={"Authorization": f"Bearer {os.environ['SOURCELOOP_API_KEY']}"},
)
data = res.json()
```

## List outcomes

`GET /v1/outcomes`

Which outcomes this workspace can be measured by

Requires scope: `metrics:read`

The companion to /schema, and the one to read before sending `outcome` or
`outcome_values` to /metrics. /schema lists what KINDS of thing can be
counted and is identical for every customer. This says which of them THIS
workspace has data for, and what its own stage ladder is called, because a
CRM ladder is renamed by its own admins and a lead-gen customer has no deals
at all.

Every outcome is listed, including ones this workspace has never produced.
Those come back with `available: false` and an empty `values` list rather
than being omitted, so a client can say "you have no deals yet" instead of
silently dropping the option.

An empty `values` list means one of two things, and `available` tells them
apart: conversions and revenue take no narrowing at all, whereas an
unavailable outcome has simply produced nothing here.

Guessing a stage key instead of reading it here returns an empty result that
is indistinguishable from a real zero.

### Query parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `website` | string | no | Website domain, e.g. acme.com. Required only when the key covers more than one. |

### Responses

- `200` One entry per outcome, each with its values and availability
- `403` Something was wrong with the request or the credential.
- `429` Too many requests for this workspace in the current minute (`rate-limit-exceeded`), the monthly allowance used (`quota-exceeded`), or too many analytics queries running at once (`too-many-concurrent`). Wait Retry-After seconds and repeat the request unchanged.

### Example (cURL)

```bash
curl -s -X GET "https://app.sourceloop.ai/api/v1/outcomes?website=acme.com" \
  -H "Authorization: Bearer $SOURCELOOP_API_KEY"
```

### Example (Node)

```javascript
const res = await fetch(
  "https://app.sourceloop.ai/api/v1/outcomes?website=acme.com",
  {
    method: "GET",
    headers: {
      Authorization: `Bearer ${process.env.SOURCELOOP_API_KEY}`,
    },
  },
);

const data = await res.json();
```

### Example (Python)

```python
import os, requests

res = requests.get(
    "https://app.sourceloop.ai/api/v1/outcomes?website=acme.com",
    headers={"Authorization": f"Bearer {os.environ['SOURCELOOP_API_KEY']}"},
)
data = res.json()
```

## Get schema

`GET /v1/schema`

Every metric, dimension and filter operator

Requires: any valid API key.

Generated from the same registry the query compiler uses, so it cannot drift from behaviour. Read this instead of guessing names.

### Responses

- `200` Schema document
- `429` Too many requests for this workspace in the current minute (`rate-limit-exceeded`), the monthly allowance used (`quota-exceeded`), or too many analytics queries running at once (`too-many-concurrent`). Wait Retry-After seconds and repeat the request unchanged.

### Example (cURL)

```bash
curl -s -X GET "https://app.sourceloop.ai/api/v1/schema" \
  -H "Authorization: Bearer $SOURCELOOP_API_KEY"
```

### Example (Node)

```javascript
const res = await fetch(
  "https://app.sourceloop.ai/api/v1/schema",
  {
    method: "GET",
    headers: {
      Authorization: `Bearer ${process.env.SOURCELOOP_API_KEY}`,
    },
  },
);

const data = await res.json();
```

### Example (Python)

```python
import os, requests

res = requests.get(
    "https://app.sourceloop.ai/api/v1/schema",
    headers={"Authorization": f"Bearer {os.environ['SOURCELOOP_API_KEY']}"},
)
data = res.json()
```

## List websites

`GET /v1/websites`

Websites this key can reach

Requires: any valid API key.

With each one's timezone and currency, which every other response is expressed in.

### Responses

- `200` Websites
- `429` Too many requests for this workspace in the current minute (`rate-limit-exceeded`), the monthly allowance used (`quota-exceeded`), or too many analytics queries running at once (`too-many-concurrent`). Wait Retry-After seconds and repeat the request unchanged.

### Example (cURL)

```bash
curl -s -X GET "https://app.sourceloop.ai/api/v1/websites" \
  -H "Authorization: Bearer $SOURCELOOP_API_KEY"
```

### Example (Node)

```javascript
const res = await fetch(
  "https://app.sourceloop.ai/api/v1/websites",
  {
    method: "GET",
    headers: {
      Authorization: `Bearer ${process.env.SOURCELOOP_API_KEY}`,
    },
  },
);

const data = await res.json();
```

### Example (Python)

```python
import os, requests

res = requests.get(
    "https://app.sourceloop.ai/api/v1/websites",
    headers={"Authorization": f"Bearer {os.environ['SOURCELOOP_API_KEY']}"},
)
data = res.json()
```
