# Email profile

> POST /email/profile returns what an email address makes public: its Gravatar profile and verified accounts, its provider type and the company behind its domain.

`POST https://api.qelka.com/v1/email/profile`

See what an email address makes public, and nothing more: the Gravatar profile its owner created, with name, location, job title and verified accounts; whether the domain is a free, disposable or corporate provider; and, for a corporate domain, the company name its homepage publishes. Each lookup costs 1 credit when Gravatar answered, whether a profile exists or not.

## Request

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `email` | string | Yes | none | The email address, 3 to 320 characters. |
| `fresh` | boolean | No | `false` | `true` skips the 3-day result cache and asks Gravatar again. |

The address is trimmed and lowercased, then sent to Gravatar as its SHA-256 hash, the form the Gravatar API expects.

```bash title="cURL"
curl https://api.qelka.com/v1/email/profile \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "support@gravatar.com"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/email/profile', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ email: 'support@gravatar.com' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/email/profile",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"email": "support@gravatar.com"},
    timeout=30,
)
result = response.json()
print(result)
```
```php title="PHP"
<?php
$ch = curl_init('https://api.qelka.com/v1/email/profile');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('QELKA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['email' => 'support@gravatar.com']),
    CURLOPT_TIMEOUT => 30,
]);
$result = json_decode(curl_exec($ch), true);
print_r($result);
```
```go title="Go"
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{"email": "support@gravatar.com"})
	request, _ := http.NewRequest(http.MethodPost, "https://api.qelka.com/v1/email/profile", bytes.NewReader(payload))
	request.Header.Set("Authorization", "Bearer "+os.Getenv("QELKA_API_KEY"))
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(response.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result)
}
```
```ruby title="Ruby"
require 'json'
require 'net/http'

uri = URI('https://api.qelka.com/v1/email/profile')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('QELKA_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate({ email: 'support@gravatar.com' })

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 30) do |http|
  http.request(request)
end
result = JSON.parse(response.body)
puts result
```

## Response

Read `status` first: it is the status of the Gravatar profile. `domain` is always set.

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this lookup: `lkp_` followed by 26 characters. |
| `object` | string | Always `email_profile`. |
| `input` | string | The `email` you sent, without surrounding spaces. |
| `email` | string | The normalized address: trimmed and lowercased. |
| `status` | string | `found`, `not_found` or `unavailable`: the same as `gravatar.status`. |
| `domain.name` | string | The domain of the address. |
| `domain.type` | string | `free` (a webmail provider anyone can sign up to), `disposable` (a throwaway inbox service) or `corporate` (any other domain). |
| `domain.company` | string or null | For a `corporate` domain, the company name its homepage publishes: Organization structured data, else the site name tag, else the part of the title that names the domain. |
| `domain.website` | string or null | The homepage that was read, after redirects. |
| `gravatar.status` | string | `found`, `not_found` or `unavailable`. |
| `gravatar.hash` | string | The SHA-256 hash of the address, as sent to Gravatar. |
| `gravatar.profile_url` | string or null | The public Gravatar profile. |
| `gravatar.avatar_url` | string or null | The avatar image URL. |
| `gravatar.display_name` | string or null | The display name. |
| `gravatar.location` | string or null | The location. |
| `gravatar.job_title` | string or null | The job title. |
| `gravatar.company` | string or null | The company. |
| `gravatar.description` | string or null | The about text. |
| `gravatar.pronouns` | string or null | The pronouns. |
| `gravatar.verified_accounts` | array of objects | Accounts on other services that the owner verified on Gravatar. |
| `gravatar.verified_accounts.platform` | string | The platform, such as `github`, `mastodon` or `website`. |
| `gravatar.verified_accounts.name` | string | The display name of the platform or service. |
| `gravatar.verified_accounts.url` | string | The account URL. |
| `credits_used` | integer | Credits debited for this call: 1 unless `status` is `unavailable` or the key is a test key. |
| `cached` | boolean | `true` when the answer came from the 3-day cache. |

```json title="Response"
{
  "id": "lkp_01M8CEGAVHVA2B57K1TRAG8GS6",
  "object": "email_profile",
  "input": "support@gravatar.com",
  "email": "support@gravatar.com",
  "status": "found",
  "domain": {
    "name": "gravatar.com",
    "type": "corporate",
    "company": "Gravatar",
    "website": "https://gravatar.com/"
  },
  "gravatar": {
    "status": "found",
    "hash": "69088d359a89802f186de20588f2e6e7652b4efcabfa3df03d6f97d3f8cb5425",
    "profile_url": "https://gravatar.com/gravatarsupport",
    "avatar_url": "https://2.gravatar.com/avatar/cd3439d70db924bedd43a519f394a350d70abc6b6661aadc297ef84163ece083",
    "display_name": "Gravatar Support",
    "location": "The Internet",
    "job_title": null,
    "company": null,
    "description": null,
    "pronouns": null,
    "verified_accounts": []
  },
  "credits_used": 1,
  "cached": false
}
```

## Act on the status

| `status` | What it means | What to do | Billed |
|---|---|---|---|
| `found` | The owner of the address created a public Gravatar profile. | Use the `gravatar` fields. | Yes, and cached 3 days |
| `not_found` | No public Gravatar profile uses this address. Most addresses have none. | Use `domain` alone. | Yes, and cached 3 days |
| `unavailable` | Gravatar did not answer within 5 seconds or answered an error. | Try again later. | No, and not cached |

This endpoint does not say whether the mailbox exists: use [email verification](https://qelka.com/docs/api-reference/email) for that.

## Where the data comes from

1. The Gravatar REST API, `GET /v3/profiles/{hash}`: only the profile the owner chose to make public.
2. The free and disposable provider lists of the [email verification](https://qelka.com/docs/api-reference/email) endpoint, for `domain.type`.
3. For a corporate domain, its homepage, read after robots.txt like the [website contacts](https://qelka.com/docs/api-reference/website) endpoint does. A homepage that redirects to another domain gives no company name.

Nothing comes from people-search sites, data brokers, breaches or social networks.

## What the API keeps

The API returns only what the owner of the address published on Gravatar and what the company publishes on its own site. The request log keeps the address masked. People can hide or delete their Gravatar profile at any time; a cached result disappears after at most 3 days.

## Examples

### Look up an address with a test key

Test keys return a simulated profile without calling Gravatar. With a test key in `QELKA_API_KEY`, this request returns:

```bash title="cURL"
curl https://api.qelka.com/v1/email/profile \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "jane@example.com"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/email/profile', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ email: 'jane@example.com' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/email/profile",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"email": "jane@example.com"},
    timeout=30,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8CH2S0HGX7CQ2PW9RMA5TBN",
  "object": "email_profile",
  "input": "jane@example.com",
  "email": "jane@example.com",
  "status": "found",
  "domain": {
    "name": "example.com",
    "type": "corporate",
    "company": "Example Company",
    "website": "https://example.com/"
  },
  "gravatar": {
    "status": "found",
    "hash": "8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d",
    "profile_url": "https://gravatar.com/simulated",
    "avatar_url": "https://gravatar.com/avatar/8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d",
    "display_name": "Simulated Person",
    "location": "Example City",
    "job_title": "Engineer",
    "company": "Example Company",
    "description": "A simulated Gravatar profile returned to test keys.",
    "pronouns": null,
    "verified_accounts": [
      { "platform": "github", "name": "GitHub", "url": "https://github.com/example" }
    ]
  },
  "credits_used": 0,
  "cached": false
}
```

## Errors

| Status | Type | When |
|---|---|---|
| 400 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | `email` is missing, shorter than 3 or longer than 320 characters, the body is not a JSON object, or it has a field the request table does not list |
| 401 | [invalid_api_key](https://qelka.com/docs/errors#invalid_api_key) | The key is missing, unknown or revoked |
| 402 | [insufficient_credits](https://qelka.com/docs/errors#insufficient_credits) | Your balance is less than 1 credit (live keys only) |
| 403 | [forbidden](https://qelka.com/docs/errors#forbidden) | The key is restricted to other endpoints |
| 405 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | The method is not `POST` |
| 422 | [unprocessable_input](https://qelka.com/docs/errors#unprocessable_input) | `email` is not a valid email address |
| 429 | [rate_limited](https://qelka.com/docs/errors#rate_limited) | Too many requests: wait `Retry-After` seconds |
| 500 | [internal_error](https://qelka.com/docs/errors#internal_error) | Unexpected error on our side: retry with backoff |

No error is billed. When Gravatar does not answer, the response is a `200` with `status` `unavailable` and `credits_used: 0`.

## Related

- [Email profile API](https://qelka.com/products/email-profile-lookup)
- Free tools: [reverse email lookup](https://qelka.com/tools/reverse-email-lookup), [Gravatar checker](https://qelka.com/tools/gravatar-checker)
- [Email verification](https://qelka.com/docs/api-reference/email): whether mail to the address will be delivered
- [Batch](https://qelka.com/docs/api-reference/batch): up to 100 addresses in one call, each item with `type: "email_profile"`
- [Bulk](https://qelka.com/docs/api-reference/bulk): a whole column of addresses with `type=email_profile`
- [Caching](https://qelka.com/docs/caching), [Errors](https://qelka.com/docs/errors), [Test mode](https://qelka.com/docs/test-mode)
