Authentication
OAuth and JWT authentication
Initiate OAuth login
/auth/oauth/{provider}/loginRedirects to OAuth provider login page
Parameters
| Name | Type | Location | Required | Description |
|---|---|---|---|---|
provider | string (google, github, shopify) | path | Yes | |
redirect_uri | string | query | No | Post-login redirect URL |
Code Examples
curl -X GET "https://searchaf.antfly.io/api/v1/auth/oauth/{provider}/login?redirect_uri=value" \\
-H "Authorization: Bearer YOUR_API_KEY"Responses
{
"redirect_url": "https://example.com"
}OAuth callback handler
/auth/oauth/{provider}/callbackHandles OAuth provider callback and generates JWT
Parameters
| Name | Type | Location | Required | Description |
|---|---|---|---|---|
provider | string (google, github, shopify) | path | Yes | |
code | string | query | Yes | OAuth authorization code |
state | string | query | Yes | CSRF protection state |
Code Examples
curl -X GET "https://searchaf.antfly.io/api/v1/auth/oauth/{provider}/callback?code=value&state=value" \\
-H "Authorization: Bearer YOUR_API_KEY"Responses
{
"access_token": "string",
"refresh_token": "string",
"token_type": "Bearer",
"expires_in": 3600,
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"display_name": "John Doe",
"avatar_url": "https://example.com/avatar.jpg",
"created_at": "2025-10-02T15:30:00Z",
"updated_at": "2025-10-02T15:30:00Z",
"last_login_at": "2025-10-02T15:30:00Z",
"status": "active",
"settings": {}
}
}Link OAuth provider to account
/auth/oauth/{provider}/linkInitiate OAuth flow to link provider to authenticated user account
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Parameters
| Name | Type | Location | Required | Description |
|---|---|---|---|---|
provider | string (google, github, shopify) | path | Yes | |
redirect_uri | string | query | No | Post-link redirect URL |
Code Examples
curl -X GET "https://searchaf.antfly.io/api/v1/auth/oauth/{provider}/link?redirect_uri=value" \\
-H "Authorization: Bearer YOUR_API_KEY"Responses
{
"redirect_url": "https://example.com"
}Refresh JWT token
/auth/refreshGenerate new JWT from refresh token
Request Body
Example:
{
"refresh_token": "string"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/refresh" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"refresh_token": "string"
}'Responses
{
"access_token": "string",
"refresh_token": "string",
"token_type": "Bearer",
"expires_in": 3600,
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"display_name": "John Doe",
"avatar_url": "https://example.com/avatar.jpg",
"created_at": "2025-10-02T15:30:00Z",
"updated_at": "2025-10-02T15:30:00Z",
"last_login_at": "2025-10-02T15:30:00Z",
"status": "active",
"settings": {}
}
}Sign out user
/auth/signoutClears authentication cookies (access_token and refresh_token)
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/signout" \\
-H "Authorization: Bearer YOUR_API_KEY"Responses
{
"success": true
}Exchange API key for JWT
/auth/apikey/exchangeExchange a long-lived API key for a short-lived JWT token. The JWT can then be used to authenticate subsequent search and batch requests.
Request Body
Example:
{
"api_key": "searchaf_a1b2c3d4_e5f6g7h8i9j0k1l2m3n4o5p6"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/apikey/exchange" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"api_key": "searchaf_a1b2c3d4_e5f6g7h8i9j0k1l2m3n4o5p6"
}'Responses
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 1800
}Sign up with email and password
/auth/signupCreate a new user account with email and password
Request Body
Example:
{
"email": "user@example.com",
"password": "MySecurePass123!",
"display_name": "John Doe"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/signup" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"email": "user@example.com",
"password": "MySecurePass123!",
"display_name": "John Doe"
}'Responses
{
"success": true,
"message": "Account created successfully. Please check your email to verify your account.",
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"display_name": "John Doe",
"avatar_url": "https://example.com/avatar.jpg",
"created_at": "2025-10-02T15:30:00Z",
"updated_at": "2025-10-02T15:30:00Z",
"last_login_at": "2025-10-02T15:30:00Z",
"status": "active",
"settings": {}
}
}Login with email and password
/auth/loginAuthenticate with email and password, returns JWT or 2FA challenge
Request Body
Example:
{
"email": "user@example.com",
"password": "MySecurePass123!"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/login" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"email": "user@example.com",
"password": "MySecurePass123!"
}'Responses
{
"access_token": "string",
"refresh_token": "string",
"token_type": "Bearer",
"expires_in": 3600,
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"display_name": "John Doe",
"avatar_url": "https://example.com/avatar.jpg",
"created_at": "2025-10-02T15:30:00Z",
"updated_at": "2025-10-02T15:30:00Z",
"last_login_at": "2025-10-02T15:30:00Z",
"status": "active",
"settings": {}
}
}Verify email address
/auth/verify-emailVerify email address with token from verification email
Request Body
Example:
{
"token": "string"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/verify-email" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"token": "string"
}'Responses
{
"success": true,
"message": "Email verified successfully. You can now log in."
}Resend verification email
/auth/resend-verificationResend verification email to user
Request Body
Example:
{
"email": "user@example.com"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/resend-verification" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"email": "user@example.com"
}'Responses
{
"success": true,
"message": "Verification email sent. Please check your inbox."
}Request password reset
/auth/forgot-passwordRequest password reset email
Request Body
Example:
{
"email": "user@example.com"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/forgot-password" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"email": "user@example.com"
}'Responses
{
"success": true,
"message": "If an account exists with this email, a password reset link has been sent."
}Reset password
/auth/reset-passwordReset password with token from reset email
Request Body
Example:
{
"token": "string",
"new_password": "NewSecurePass123!"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/reset-password" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"token": "string",
"new_password": "NewSecurePass123!"
}'Responses
{
"success": true,
"message": "Password reset successfully. You can now log in with your new password."
}Change password
/auth/change-passwordChange password for authenticated user
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Request Body
Example:
{
"current_password": "string",
"new_password": "string"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/change-password" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"current_password": "string",
"new_password": "string"
}'Responses
{
"success": true,
"message": "Password changed successfully"
}Setup 2FA
/auth/2fa/setupGenerate TOTP secret and QR code for setting up 2FA
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/2fa/setup" \\
-H "Authorization: Bearer YOUR_API_KEY"Responses
{
"secret": "JBSWY3DPEHPK3PXP",
"qr_code_url": "otpauth://totp/SearchAF:user@example.com?secret=JBSWY3DPEHPK3PXP&issuer=SearchAF",
"manual_entry_key": "JBSW Y3DP EHPK 3PXP"
}Verify and enable 2FA
/auth/2fa/verify-setupVerify TOTP code and enable 2FA for user account
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Request Body
Example:
{
"code": "123456",
"secret": "JBSWY3DPEHPK3PXP"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/2fa/verify-setup" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"code": "123456",
"secret": "JBSWY3DPEHPK3PXP"
}'Responses
{
"success": true,
"message": "Two-factor authentication enabled successfully",
"backup_codes": [
"ABCD-1234",
"EFGH-5678"
]
}Disable 2FA
/auth/2fa/disableDisable 2FA for user account (requires password and TOTP code)
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Request Body
Example:
{
"password": "string",
"code": "123456"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/2fa/disable" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"password": "string",
"code": "123456"
}'Responses
{
"success": true,
"message": "Two-factor authentication disabled successfully"
}Verify 2FA code during login
/auth/2fa/verifyVerify TOTP code to complete login with 2FA
Request Body
Example:
{
"temp_token": "string",
"code": "123456"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/2fa/verify" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"temp_token": "string",
"code": "123456"
}'Responses
{
"access_token": "string",
"refresh_token": "string",
"token_type": "Bearer",
"expires_in": 3600,
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"display_name": "John Doe",
"avatar_url": "https://example.com/avatar.jpg",
"created_at": "2025-10-02T15:30:00Z",
"updated_at": "2025-10-02T15:30:00Z",
"last_login_at": "2025-10-02T15:30:00Z",
"status": "active",
"settings": {}
}
}Regenerate backup codes
/auth/2fa/backup-codesGenerate new set of backup codes (invalidates old ones)
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Code Examples
curl -X GET "https://searchaf.antfly.io/api/v1/auth/2fa/backup-codes" \\
-H "Authorization: Bearer YOUR_API_KEY"Responses
{
"backup_codes": [
"ABCD-1234",
"EFGH-5678",
"IJKL-9012"
]
}Verify backup code during login
/auth/2fa/verify-backupVerify backup code to complete login when TOTP is unavailable
Request Body
Example:
{
"temp_token": "string",
"backup_code": "ABCD-1234"
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/2fa/verify-backup" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"temp_token": "string",
"backup_code": "ABCD-1234"
}'Responses
{
"access_token": "string",
"refresh_token": "string",
"token_type": "Bearer",
"expires_in": 3600,
"user": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"display_name": "John Doe",
"avatar_url": "https://example.com/avatar.jpg",
"created_at": "2025-10-02T15:30:00Z",
"updated_at": "2025-10-02T15:30:00Z",
"last_login_at": "2025-10-02T15:30:00Z",
"status": "active",
"settings": {}
}
}Initiate OAuth re-authentication for sensitive operations
/auth/reauth/initiateStart OAuth re-authentication flow for sensitive operations like ownership transfer
Security
Provide your bearer token in the Authorization header when making requests to protected resources.
Example: Authorization: Bearer YOUR_API_KEY
Request Body
Example:
{
"operation": "transfer_ownership",
"operation_data": {}
}
Code Examples
curl -X POST "https://searchaf.antfly.io/api/v1/auth/reauth/initiate" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"operation": "transfer_ownership",
"operation_data": {}
}'Responses
{
"provider": "google",
"auth_url": "https://example.com"
}OAuth re-authentication callback
/auth/oauth/{provider}/callback/reauthHandle OAuth callback for re-authentication flow
Parameters
| Name | Type | Location | Required | Description |
|---|---|---|---|---|
provider | string (google, github, shopify) | path | Yes | |
code | string | query | Yes | OAuth authorization code |
state | string | query | Yes | CSRF protection state |
Code Examples
curl -X GET "https://searchaf.antfly.io/api/v1/auth/oauth/{provider}/callback/reauth?code=value&state=value" \\
-H "Authorization: Bearer YOUR_API_KEY"Responses
{
"success": true
}