API Reference

Complete API documentation with examples and code snippets

Introduction

All API endpoints require authentication via Bearer token. Include the token in the Authorization header.

Base URL

https://brandpass.com/api
GET/api/user/organization

Get Organization

Retrieves the current user's active organization details including name, members, and brands.

Headers

Authorization: Bearer <token>

Response

{
  "_id": "507f1f77bcf86cd799439011",
  "name": "Acme Corporation",
  "logo": "https://example.com/logo.png",
  "createdAt": "2024-01-15T10:30:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "members": [
    {
      "userId": "user123",
      "role": "OWNER",
      "status": "active"
    }
  ],
  "brandCount": 3
}

Example Request

const response = await fetch('/api/user/organization', {
  headers: {
    'Authorization': `Bearer ${token}`
  }
});
const organization = await response.json();
GET/api/user/brands

Get Brands

Retrieves all brands associated with the user's organization. Returns brand details including name, logo, and campaign count.

Headers

Authorization: Bearer <token>

Response

[
  {
    "_id": "507f1f77bcf86cd799439012",
    "name": "Main Brand",
    "logo": "https://example.com/brand-logo.png",
    "organizationId": "507f1f77bcf86cd799439011",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z",
    "campaignCount": 5,
    "creatorCount": 12
  },
  {
    "_id": "507f1f77bcf86cd799439013",
    "name": "Secondary Brand",
    "logo": "https://example.com/brand-logo-2.png",
    "organizationId": "507f1f77bcf86cd799439011",
    "createdAt": "2024-01-16T14:20:00.000Z",
    "updatedAt": "2024-01-16T14:20:00.000Z",
    "campaignCount": 2,
    "creatorCount": 8
  }
]

Example Request

const response = await fetch('/api/user/brands', {
  headers: {
    'Authorization': `Bearer ${token}`
  }
});
const brands = await response.json();

Error Responses

All endpoints return standard HTTP status codes and error messages.

401 Unauthorized

{
  "error": "Invalid or missing authentication token"
}

404 Not Found

{
  "error": "Resource not found"
}

500 Internal Server Error

{
  "error": "Internal server error"
}