# Business API

Manage business profiles, services, availability, and media.

## Endpoints

### Create Business Profile

Create a new business profile.

```http
POST /business/profile
```

**Request Body**:

```json
{
  "name": "Artisan Coffee Roasters",
  "category": "restaurants",
  "description": "Family-owned coffee roastery specializing in single-origin beans",
  "tagline": "Locally roasted, globally inspired",
  "location": {
    "address": {
      "street": "123 Main St",
      "city": "Portland",
      "state": "OR",
      "country": "USA",
      "postalCode": "97201"
    },
    "coordinates": {
      "lat": 45.5231,
      "lon": -122.6765
    }
  },
  "contact": {
    "phone": "+1-503-555-0123",
    "email": "info@artisancoffee.com",
    "website": "https://artisancoffee.com"
  },
  "services": [
    {
      "name": "Espresso Drinks",
      "description": "Handcrafted espresso beverages",
      "category": "beverages",
      "pricing": {
        "type": "range",
        "minAmount": 4,
        "maxAmount": 7,
        "currency": "USD"
      },
      "bookable": false,
      "requiresQuote": false
    }
  ],
  "hours": {
    "monday": { "open": "07:00", "close": "18:00" },
    "tuesday": { "open": "07:00", "close": "18:00" },
    "wednesday": { "open": "07:00", "close": "18:00" },
    "thursday": { "open": "07:00", "close": "18:00" },
    "friday": { "open": "07:00", "close": "18:00" },
    "saturday": { "open": "08:00", "close": "17:00" },
    "sunday": { "closed": true }
  }
}
```

**Response** (201 Created):

```json
{
  "success": true,
  "data": {
    "id": "biz_abc123",
    "name": "Artisan Coffee Roasters",
    "status": "draft",
    "createdAt": "2025-12-07T10:30:00Z"
  }
}
```

### Get Business Profile

Retrieve a business profile by ID.

```http
GET /business/profile/{businessId}
```

**Response** (200 OK):

```json
{
  "success": true,
  "data": {
    "id": "biz_abc123",
    "name": "Artisan Coffee Roasters",
    "category": "restaurants",
    "description": "...",
    "location": { ... },
    "contact": { ... },
    "services": [ ... ],
    "hours": { ... },
    "media": {
      "logo": "https://cdn.aidp.dev/logos/abc123.jpg",
      "photos": [ ... ]
    },
    "trust": {
      "verificationLevel": "certified",
      "averageRating": 4.8,
      "totalReviews": 342
    },
    "status": "published",
    "createdAt": "2025-12-07T10:30:00Z",
    "updatedAt": "2025-12-07T15:45:00Z"
  }
}
```

### Update Business Profile

Update an existing business profile.

```http
PATCH /business/profile/{businessId}
```

**Request Body** (partial update):

```json
{
  "description": "Updated description",
  "hours": {
    "monday": { "open": "06:00", "close": "19:00" }
  }
}
```

**Response** (200 OK):

```json
{
  "success": true,
  "data": {
    "id": "biz_abc123",
    "updatedAt": "2025-12-07T16:00:00Z"
  }
}
```

### Delete Business Profile

Delete a business profile.

```http
DELETE /business/profile/{businessId}
```

**Response** (200 OK):

```json
{
  "success": true,
  "data": {
    "id": "biz_abc123",
    "deleted": true
  }
}
```

### Get Profile Status

Check profile completion and publishing status.

```http
GET /business/profile/status
```

**Response** (200 OK):

```json
{
  "success": true,
  "data": {
    "profileComplete": true,
    "completionPercentage": 95,
    "status": "published",
    "missingFields": ["virtualTour"],
    "recommendations": [
      "Add AI-exclusive content to stand out",
      "Upload more photos (5+ recommended)"
    ]
  }
}
```

## Services Management

### Add Service

Add a new service to your business.

```http
POST /business/profile/{businessId}/services
```

**Request Body**:

```json
{
  "name": "Coffee Tasting Experience",
  "description": "Guided tasting of 4 single-origin coffees",
  "category": "experiences",
  "pricing": {
    "type": "fixed",
    "amount": 25,
    "currency": "USD"
  },
  "duration": 60,
  "bookable": true,
  "requiresQuote": false
}
```

**Response** (201 Created):

```json
{
  "success": true,
  "data": {
    "id": "svc_xyz789",
    "name": "Coffee Tasting Experience",
    "createdAt": "2025-12-07T10:30:00Z"
  }
}
```

### Update Service

Update an existing service.

```http
PATCH /business/profile/{businessId}/services/{serviceId}
```

### Delete Service

Remove a service.

```http
DELETE /business/profile/{businessId}/services/{serviceId}
```

## Media Management

### Upload Media

Upload photos, videos, or logo.

```http
POST /business/profile/media
Content-Type: multipart/form-data
```

**Request**:

```
file: [binary data]
type: "photo" | "video" | "logo"
```

**Response** (201 Created):

```json
{
  "success": true,
  "data": {
    "url": "https://cdn.aidp.dev/photos/abc123.jpg",
    "type": "photo",
    "uploadedAt": "2025-12-07T10:30:00Z"
  }
}
```

### Delete Media

Remove uploaded media.

```http
DELETE /business/profile/media/{mediaId}
```

## AI-Exclusive Content

### Update Exclusive Content

Add or update AI-exclusive content.

```http
PATCH /business/profile/{businessId}/exclusive-content
```

**Request Body**:

```json
{
  "insiderTips": "Ask for the Ethiopian Yirgacheffe - not on menu but always available",
  "localSecrets": "We source beans directly from Colombian farmers",
  "behindTheScenes": "We roast every Tuesday and Thursday morning",
  "sustainabilityPractices": "100% compostable packaging, solar-powered roasting"
}
```

**Response** (200 OK):

```json
{
  "success": true,
  "data": {
    "updated": true,
    "visibilityScore": 87,
    "uniquenessScore": 92
  }
}
```

## Availability Management

### Update Hours

Update business hours.

```http
PATCH /business/profile/{businessId}/hours
```

**Request Body**:

```json
{
  "monday": { "open": "07:00", "close": "18:00" },
  "tuesday": { "open": "07:00", "close": "18:00" }
}
```

### Add Blackout Dates

Mark dates when business is closed.

```http
POST /business/profile/{businessId}/blackout-dates
```

**Request Body**:

```json
{
  "dates": ["2025-12-25", "2026-01-01"]
}
```

## Verification

### Request Verification

Request business verification.

```http
POST /business/profile/{businessId}/verification
```

**Request Body**:

```json
{
  "level": "certified",
  "documents": [
    "https://cdn.aidp.dev/docs/business-license.pdf",
    "https://cdn.aidp.dev/docs/tax-id.pdf"
  ]
}
```

**Response** (200 OK):

```json
{
  "success": true,
  "data": {
    "verificationId": "ver_abc123",
    "status": "pending",
    "estimatedReviewTime": "2-3 business days"
  }
}
```

## Error Codes

| Code                   | Description                              |
| ---------------------- | ---------------------------------------- |
| `PROFILE_NOT_FOUND`    | Business profile doesn't exist           |
| `VALIDATION_ERROR`     | Invalid request data                     |
| `DUPLICATE_PROFILE`    | Profile already exists for this business |
| `MEDIA_UPLOAD_FAILED`  | Failed to upload media file              |
| `VERIFICATION_PENDING` | Verification already in progress         |

## Examples

### TypeScript

```typescript
import { AIDPClient } from '@aidp-protocol/core';

const client = new AIDPClient({ apiKey: process.env.AIDP_API_KEY });

// Create profile
const profile = await client.business.createProfile({
  name: 'Artisan Coffee Roasters',
  category: 'restaurants',
  description: '...',
  location: { ... },
  contact: { ... }
});

// Update profile
await client.business.updateProfile(profile.id, {
  description: 'Updated description'
});

// Add service
await client.business.addService(profile.id, {
  name: 'Coffee Tasting',
  pricing: { type: 'fixed', amount: 25, currency: 'USD' }
});
```

### Python

```python
from aidp_protocol import AIDPClient

client = AIDPClient(api_key=os.environ['AIDP_API_KEY'])

# Create profile
profile = client.business.create_profile(
    name='Artisan Coffee Roasters',
    category='restaurants',
    description='...',
    location={...},
    contact={...}
)

# Update profile
client.business.update_profile(
    profile['id'],
    description='Updated description'
)
```

### cURL

```bash
# Create profile
curl -X POST https://api.aidp.dev/v1/business/profile \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Artisan Coffee Roasters",
    "category": "restaurants",
    "description": "...",
    "location": {...},
    "contact": {...}
  }'

# Get profile
curl -X GET https://api.aidp.dev/v1/business/profile/biz_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"
```

## Next Steps

* [Search API](https://amistan.gitbook.io/aidp-docs/for-developers/api-reference/search)
* [Booking API](https://github.com/gugga7/aeo/blob/main/docs/gitbook/developers/api-reference/booking.md)
* [Analytics API](https://amistan.gitbook.io/aidp-docs/for-developers/api-reference/analytics)
* [Code Examples](https://amistan.gitbook.io/aidp-docs/for-developers/examples)
