# Email to company domain

> Find the domain of the company a person works at, from their email address.

`POST https://mmkuffhlzytnmgraagbp.supabase.co/functions/v1/api-email-domain`

Send an email address and get back the **domain of the company the person works at**.

## Request

```bash
curl -X POST "https://mmkuffhlzytnmgraagbp.supabase.co/functions/v1/api-email-domain" \
  -H "Authorization: Bearer $PLATINUX_API_KEY" -H "Content-Type: application/json" \
  -d '{"email": "jane.doe@gmail.com"}'
```

| Body field | Type | Required | Notes |
|---|---|---|---|
| `email` | string | Yes | Any email address. Case and spaces don't matter |

## How the email is handled

| Email type | Example | What you get | Credits |
|---|---|---|---|
| **Work** | `priya@mail.acme.com` | The email's own domain, cleaned to the main domain: `acme.com` | **0** |
| **Temporary** | `someone@mailinator.com` | No domain, with a message | **0** |
| **Generic** (Gmail, Outlook, etc.) | `jane.doe@gmail.com` | We find the person's professional profile, take their **current** employer and return its website domain | **10**, only when found |

Generic email providers (Gmail, Outlook, Yahoo, iCloud, Proton and about 380 domains in all) and temporary-mail services (about 160) are recognised from built-in lists. Every other domain is treated as a work email.

## Responses

**Work email, `200`, free**

```json
{ "status": "found", "type": "work", "email": "lee@team.hubspot.com", "domain": "hubspot.com", "credits_charged": 0 }
```

**Generic email, company found, `200`, 10 credits**

```json
{ "status": "found", "type": "personal", "email": "jane.doe@gmail.com", "domain": "acme.com", "cached": false, "credits_charged": 10 }
```

**Generic email, asked again within 30 days, `200`, free**

```json
{ "status": "found", "type": "personal", "email": "jane.doe@gmail.com", "domain": "acme.com", "cached": true, "credits_charged": 0 }
```

**Generic email, nothing found, `200`, free**

```json
{ "status": "not_found", "type": "personal", "email": "someone@yahoo.co.in", "domain": null, "credits_charged": 0 }
```

**Temporary email, `200`, free**

```json
{ "status": "temporary_email", "type": "temporary", "email": "someone@mailinator.com", "domain": null, "credits_charged": 0,
  "message": "This is a temporary (disposable) email address, so there is no company domain." }
```

## Fields

| Field | Meaning |
|---|---|
| `status` | `found`, `not_found` or `temporary_email` |
| `type` | `work`, `personal` (a generic email such as Gmail or Outlook) or `temporary` |
| `domain` | The company's main domain (`news.acme.com` becomes `acme.com`; endings like `acme.co.uk` are kept), or `null` |
| `cached` | Generic emails only: `true` when the answer came from a lookup in the last 30 days (7 days for not found) |
| `message` | Temporary emails only |
| `credits_charged` | 0 or 10 |

## Good to know

- **Several current jobs:** the main one listed on the person's profile is used.
- **No website listed** for the employer: returned as `not_found`, free.
- **Speed:** work and temporary emails answer at once; generic emails take a few seconds.

## Errors

| HTTP | `error` | When |
|---|---|---|
| 400 | `invalid_email` | Not a valid email address |
| 401 | `unauthorized` | Missing, wrong or revoked key |
| 402 | `insufficient_credits` | A generic email needs 10 credits available |
| 405 | `method_not_allowed` | Use `POST` |
| 502 | `provider_unavailable` | A data source didn't answer. Nothing was charged; try again |
