{
    "openapi": "3.1.0",
    "info": {
        "title": "Avatarak.ir API",
        "version": "1.0.0",
        "description": "Turn an email address into an avatar and a public profile.\n\nProfile lookups need an API key (create one under *Developers* in the dashboard). Avatar images and the public profile export need no key. The email address is never sent: only its SHA-256 hash.",
        "license": {
            "name": "MIT"
        }
    },
    "servers": [
        {
            "url": "https://avatarak.ir"
        }
    ],
    "tags": [
        {
            "name": "Profiles",
            "description": "Needs an API key."
        },
        {
            "name": "Public",
            "description": "No key needed."
        }
    ],
    "paths": {
        "/api/v1/profiles/{hash}": {
            "get": {
                "tags": [
                    "Profiles"
                ],
                "operationId": "getProfile",
                "summary": "Get one profile",
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "apiKeyHeader": []
                    }
                ],
                "description": "Returns the public profile for an email hash. The answer is `404` for unknown, unverified, private and hidden profiles alike, so it cannot be used to find out whether an address has an account.",
                "parameters": [
                    {
                        "name": "hash",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Fa-f0-9]{64}$",
                            "description": "SHA-256 of the trimmed, lower-cased email address (64 hex characters).",
                            "example": "9d86ec2b59bb107bf110722c28601160b33aee06109ad44a5404231287b5fd29"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The profile.",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                }
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data"
                                    ],
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Profile"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid API key.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "message": "Invalid or missing API key."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "The key does not have the profiles:read scope.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "message": "This key does not have the \"profiles:read\" scope."
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No public profile for this hash.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "message": "Profile not found."
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Rate limit exceeded; see the Retry-After header.",
                        "headers": {
                            "Retry-After": {
                                "schema": {
                                    "type": "integer"
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "message": "Rate limit exceeded."
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/profiles/lookup": {
            "post": {
                "tags": [
                    "Profiles"
                ],
                "operationId": "lookupProfiles",
                "summary": "Look up up to 100 profiles at once",
                "security": [
                    {
                        "bearerAuth": []
                    },
                    {
                        "apiKeyHeader": []
                    }
                ],
                "description": "Send 1 to 100 hashes (duplicates are merged, upper case is accepted). The result is an object keyed by hash; a hash without a public profile is `null`.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "hashes"
                                ],
                                "properties": {
                                    "hashes": {
                                        "type": "array",
                                        "minItems": 1,
                                        "maxItems": 100,
                                        "items": {
                                            "type": "string",
                                            "pattern": "^[A-Fa-f0-9]{64}$",
                                            "description": "SHA-256 of the trimmed, lower-cased email address (64 hex characters).",
                                            "example": "9d86ec2b59bb107bf110722c28601160b33aee06109ad44a5404231287b5fd29"
                                        }
                                    }
                                }
                            },
                            "example": {
                                "hashes": [
                                    "9d86ec2b59bb107bf110722c28601160b33aee06109ad44a5404231287b5fd29",
                                    "e788ea2014693dcdb86767aceb3860a432fc626c6477a6c53016aff40726842b"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Profiles keyed by hash.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data"
                                    ],
                                    "properties": {
                                        "data": {
                                            "type": "object",
                                            "additionalProperties": {
                                                "oneOf": [
                                                    {
                                                        "$ref": "#/components/schemas/Profile"
                                                    },
                                                    {
                                                        "type": "null"
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid API key.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "message": "Invalid or missing API key."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "The key does not have the profiles:lookup scope.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "message": "This key does not have the \"profiles:lookup\" scope."
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Empty list, more than 100 hashes, or a value that is not 64 hex characters.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "message": "The hashes field must not have more than 100 items."
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Rate limit exceeded.",
                        "headers": {
                            "Retry-After": {
                                "schema": {
                                    "type": "integer"
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "message": "Rate limit exceeded."
                                }
                            }
                        }
                    }
                }
            }
        },
        "/avatar/{hash}": {
            "get": {
                "tags": [
                    "Public"
                ],
                "operationId": "getAvatar",
                "summary": "The avatar image",
                "security": [],
                "description": "A square image: JPEG, or WebP when `Accept` contains `image/webp`. When there is no public photo the response is a default image, identical for unknown, unverified and private addresses.",
                "parameters": [
                    {
                        "name": "hash",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Fa-f0-9]{64}$",
                            "description": "SHA-256 of the trimmed, lower-cased email address (64 hex characters).",
                            "example": "9d86ec2b59bb107bf110722c28601160b33aee06109ad44a5404231287b5fd29"
                        }
                    },
                    {
                        "name": "s",
                        "in": "query",
                        "description": "Size in pixels, 16 to 512 (alias: `size`).",
                        "schema": {
                            "type": "integer",
                            "minimum": 16,
                            "maximum": 512,
                            "default": 80
                        }
                    },
                    {
                        "name": "d",
                        "in": "query",
                        "description": "What to return when there is no public photo (alias: `default`).",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "mp",
                                "identicon",
                                "blank",
                                "404"
                            ],
                            "default": "mp"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The image.",
                        "headers": {
                            "ETag": {
                                "schema": {
                                    "type": "string"
                                }
                            },
                            "Cache-Control": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        },
                        "content": {
                            "image/jpeg": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            },
                            "image/webp": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            },
                            "image/svg+xml": {
                                "schema": {
                                    "type": "string"
                                }
                            },
                            "image/png": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "304": {
                        "description": "Not modified (send If-None-Match)."
                    },
                    "404": {
                        "description": "Only with `d=404` and no public photo."
                    }
                }
            }
        },
        "/{username}.json": {
            "get": {
                "tags": [
                    "Public"
                ],
                "operationId": "getPublicProfile",
                "summary": "Public profile data",
                "security": [],
                "description": "Everything the public profile page shows, as JSON. Also available as `.md`, `.vcf` and `.card`. Social handles are full URLs here.",
                "parameters": [
                    {
                        "name": "username",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z][A-Za-z0-9_]{2,31}$",
                            "example": "javid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The profile.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/PublicProfile"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No such public profile."
                    }
                }
            }
        }
    },
    "webhooks": {
        "profile.updated": {
            "post": {
                "summary": "Delivered when: profile.updated",
                "description": "Signed with `Avatarak-Signature: t=<unix>,v1=<HMAC-SHA256(secret, \"<t>.<raw body>\")>`. Answer 2xx within 8 seconds; failures are retried.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Acknowledged"
                    }
                }
            }
        },
        "avatar.changed": {
            "post": {
                "summary": "Delivered when: avatar.changed",
                "description": "Signed with `Avatarak-Signature: t=<unix>,v1=<HMAC-SHA256(secret, \"<t>.<raw body>\")>`. Answer 2xx within 8 seconds; failures are retried.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Acknowledged"
                    }
                }
            }
        },
        "verification.added": {
            "post": {
                "summary": "Delivered when: verification.added",
                "description": "Signed with `Avatarak-Signature: t=<unix>,v1=<HMAC-SHA256(secret, \"<t>.<raw body>\")>`. Answer 2xx within 8 seconds; failures are retried.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Acknowledged"
                    }
                }
            }
        },
        "verification.removed": {
            "post": {
                "summary": "Delivered when: verification.removed",
                "description": "Signed with `Avatarak-Signature: t=<unix>,v1=<HMAC-SHA256(secret, \"<t>.<raw body>\")>`. Answer 2xx within 8 seconds; failures are retried.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Acknowledged"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "avk_…",
                "description": "Your API key: `Authorization: Bearer avk_…`"
            },
            "apiKeyHeader": {
                "type": "apiKey",
                "in": "header",
                "name": "X-API-Key",
                "description": "The same key in an alternative header."
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "required": [
                    "message"
                ],
                "properties": {
                    "message": {
                        "type": "string"
                    },
                    "errors": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "VerifiedAccount": {
                "type": "object",
                "required": [
                    "network",
                    "identifier",
                    "url"
                ],
                "properties": {
                    "network": {
                        "type": "string",
                        "enum": [
                            "website",
                            "github",
                            "linkedin",
                            "telegram"
                        ]
                    },
                    "identifier": {
                        "type": "string"
                    },
                    "url": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "null for LinkedIn, which has no public address."
                    }
                }
            },
            "WebhookEvent": {
                "type": "object",
                "required": [
                    "id",
                    "type",
                    "created_at",
                    "data"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "profile.updated",
                            "avatar.changed",
                            "verification.added",
                            "verification.removed",
                            "ping"
                        ]
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "data": {
                        "type": "object",
                        "properties": {
                            "username": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "profile_url": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "uri"
                            },
                            "email_hashes": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            },
                            "changed": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            },
                            "network": {
                                "type": "string"
                            },
                            "identifier": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "Link": {
                "type": "object",
                "required": [
                    "label",
                    "url"
                ],
                "properties": {
                    "label": {
                        "type": "string"
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "description": {
                        "type": "string"
                    },
                    "image": {
                        "type": "string",
                        "format": "uri"
                    }
                }
            },
            "Profile": {
                "type": "object",
                "required": [
                    "hash",
                    "username",
                    "profile_url",
                    "name_fa",
                    "name_en",
                    "headline",
                    "location",
                    "bio",
                    "website",
                    "socials",
                    "links",
                    "verified_accounts",
                    "language",
                    "avatar_url"
                ],
                "properties": {
                    "hash": {
                        "type": "string",
                        "pattern": "^[A-Fa-f0-9]{64}$",
                        "description": "SHA-256 of the trimmed, lower-cased email address (64 hex characters).",
                        "example": "9d86ec2b59bb107bf110722c28601160b33aee06109ad44a5404231287b5fd29"
                    },
                    "username": {
                        "type": "string"
                    },
                    "profile_url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "name_fa": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "name_en": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "headline": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "location": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "bio": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "website": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uri"
                    },
                    "socials": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "string"
                        },
                        "description": "network → handle, e.g. {\"github\": \"javid\"}"
                    },
                    "links": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Link"
                        }
                    },
                    "verified_accounts": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/VerifiedAccount"
                        }
                    },
                    "language": {
                        "type": "string",
                        "enum": [
                            "fa",
                            "en"
                        ],
                        "description": "The language of headline, location, bio and links. Bilingual profiles accept ?lang=fa|en."
                    },
                    "avatar_url": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uri"
                    }
                }
            },
            "PublicProfile": {
                "type": "object",
                "description": "The public export; see the docs for every field.",
                "properties": {
                    "username": {
                        "type": "string"
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "display_name": {
                        "type": "string"
                    },
                    "name_fa": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "name_en": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "headline": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "location": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "bio": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "website": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "avatar_url": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "verified": {
                        "type": "boolean"
                    },
                    "socials": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "string",
                            "format": "uri"
                        }
                    },
                    "links": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Link"
                        }
                    },
                    "verified_accounts": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/VerifiedAccount"
                        }
                    },
                    "language": {
                        "type": "string",
                        "enum": [
                            "fa",
                            "en"
                        ]
                    },
                    "languages": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "enum": [
                                "fa",
                                "en"
                            ]
                        },
                        "description": "Languages this page is available in. Bilingual profiles also carry a \"translations\" object and accept ?lang=fa|en."
                    },
                    "translations": {
                        "type": "object",
                        "description": "Only on bilingual profiles: the texts of each language, keyed fa / en."
                    },
                    "gallery": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "format": "uri"
                                },
                                "thumb_url": {
                                    "type": "string",
                                    "format": "uri"
                                },
                                "caption": {
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "width": {
                                    "type": "integer"
                                },
                                "height": {
                                    "type": "integer"
                                }
                            }
                        }
                    },
                    "sections": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "title": {
                                    "type": "string"
                                },
                                "body": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "updated_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            }
        }
    }
}