# The Social Martini Platform API

The businesses and communities of one city, as an API: read and (as it grows) act on what a business or community owns. For browsing local events, clubs, restaurants, shops, deals and jobs as a visitor, use the MCP server instead (see "Other ways in" below).

- Base URL: `https://api.thesocialmartini.com/v1`
- OpenAPI 3.1 document: https://api.thesocialmartini.com/v1/openapi.json
- API catalog (RFC 9727): https://www.thesocialmartini.com/.well-known/api-catalog

## Authentication and access types

Operations that read an owner's data need an API key, sent in the `X-API-Key` header. Each key belongs to one business or community and carries access types named `api:<resource>:<action>`. What a key can do is its access types narrowed to what its owner's plan grants at the moment of the call.

| Access type | Grants |
| --- | --- |
| `api:profile:read` | Read the profile of the business or community that owns the key |

### Getting a key

The owner of a business or community creates keys in their portal under **Settings → API keys** (staff cannot). A key looks like `tsm_live_<id>_<secret>`: the `tsm_live_<id>` part names it wherever it is listed, and the whole key is shown once, when it is created. How many keys an owner may hold depends on their plan. A key expires 90 days after it is made; rotating it gives a new key and keeps the old one working for 24 hours so you can switch over. Our team can also issue a key for an owner, who then reveals it in the portal within 7 days; we never see it. A revoked key can keep working for up to a minute.

Each operation lists the access type it needs in the OpenAPI document (`x-access-types` lists them all). A missing, invalid, revoked or expired key gets `401`; a key without the needed access type gets `403`.

## Operations

### `GET /v1/profile`

Needs `api:profile:read`. The public profile of the business or community that owns the key.

```bash
curl -H "X-API-Key: $KEY" "https://api.thesocialmartini.com/v1/profile"
```

`200` returns `object` (`"profile"`), `id`, `owner_type`, `name`, `slug`, `description`, `logo_url`, `cover_image_url`, `created_at` and `updated_at`.

### `GET /v1/storefronts/resolve?slug={slug}`

Public, no key. The business and theme a storefront subdomain renders.

```bash
curl "https://api.thesocialmartini.com/v1/storefronts/resolve?slug=example"
```

`200` returns `object` (`"storefront"`), `slug`, `business_id`, `business_name`, `business_slug` and `theme`; `404` if no storefront has the slug.

## Errors

Every error is RFC 9457 problem details (`application/problem+json`): `type`, `title`, `status`, `detail` and `instance`. A validation error adds `errors: [{field, message}]`.

## Versioning

This is a published contract. Within `/v1`, changes are additive only (new operations, optional fields, new enum values); a breaking change ships as `/v2`, and `/v1` is retired after a published deprecation window, announced with `Deprecation` and `Sunset` headers.

## Other ways in

- MCP server: `https://mcp.thesocialmartini.com/mcp` (Streamable HTTP). Public tools need no sign-in; signed-in tools use OAuth 2.1 with the scopes listed at https://mcp.thesocialmartini.com/.well-known/oauth-protected-resource
- Site guide for agents: https://www.thesocialmartini.com/llms.txt
