{
  "info": {
    "name": "ConnectGain API - Complete Collection v4",
    "description": "Complete API collection for ConnectGain platform including all Edge Functions and Supabase REST API endpoints with full CRUD operations.\n\n## Setup Instructions\n\n1. Import this collection into Postman\n2. Set collection variables:\n   - `url`: `https://txpaxbxhnvnhsjwwaeoy.supabase.co`\n   - `anon_key`: Your Supabase anon key (from Supabase Dashboard \u2192 Settings \u2192 API)\n   - `api_key`: Your ConnectGain API key (format: `cg_xxxxxx`, use Generate API Key endpoint)\n   - `organization_id`: Your organization UUID\n   - Other resource IDs as needed for testing\n\n3. Start testing APIs!\n\n## Authentication Patterns \u2705\n\n### \u2705 External APIs (Recommended for External Systems)\n- **Header**: `X-API-Key: cg_xxxxxx`\n- **Usage**: External system integration, third-party apps\n- **Security**: Automatic organization filtering, scoped permissions\n- **Examples**: Search Contacts, Insert Message, Search Companies\n\n### \ud83d\udd27 Edge Functions (Internal/Advanced Use)\n- **Header**: `Authorization: Bearer {{anon_key}}`\n- **Usage**: Internal application features, advanced operations\n- **Examples**: Message sending, imports, webhooks\n\n### \ud83d\udcca Direct REST API (Database Access)\n- **Headers**: Both `apikey: {{anon_key}}` AND `Authorization: Bearer {{anon_key}}`\n- **Usage**: Direct database operations, advanced queries\n- **Examples**: CRUD operations on contacts, deals, etc.\n\n## \ud83d\ude80 Quick Start\nFor external integrations, start with the \"External API - X-API-Key Authentication\" section!\n\n## Documentation\n\nSee `docs/COMPLETE_API_DOCUMENTATION.md` for complete API documentation.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_postman_id": "connectgain-api-complete-v3",
    "version": "4.0.0"
  },
  "item": [
    {
      "name": "Edge Functions - Message Sending",
      "item": [
        {
          "name": "WhatsApp Lite - Send Message",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"201001383533\",\n  \"message\": \"Hello from ConnectGain!\",\n  \"suitId\": \"{{suit_id}}\",\n  \"organizationId\": \"{{organization_id}}\",\n  \"contactName\": \"John Doe\",\n  \"from\": \"AIBot\",\n  \"conversationId\": \"{{conversation_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/whatsapp-lite-send",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "whatsapp-lite-send"
              ]
            },
            "description": "Send messages via WhatsApp Lite (AppGain integration). Requires either suitId or organizationId. Automatically creates or finds contacts and conversations."
          },
          "response": []
        },
        {
          "name": "WhatsApp Cloud - Send Message",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"phone_number\",\n  \"message\": \"Hello via WhatsApp Cloud!\",\n  \"conversationId\": \"{{conversation_id}}\",\n  \"accessToken\": \"facebook_access_token\",\n  \"phoneNumberId\": \"phone_number_id\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/whatsapp-cloud-send",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "whatsapp-cloud-send"
              ]
            }
          }
        },
        {
          "name": "Facebook Messenger - Send Message",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"user_psid\",\n  \"message\": \"Hello via Messenger!\",\n  \"conversationId\": \"{{conversation_id}}\",\n  \"accessToken\": \"messenger_access_token\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/messenger-send",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "messenger-send"
              ]
            }
          }
        },
        {
          "name": "Instagram - Send Message",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"instagram_user_id\",\n  \"message\": \"Hello via Instagram!\",\n  \"conversationId\": \"{{conversation_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/instagram-send",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "instagram-send"
              ]
            }
          }
        },
        {
          "name": "Telegram - Send Message",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"telegram_chat_id\",\n  \"message\": \"Hello via Telegram!\",\n  \"conversationId\": \"{{conversation_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/telegram-send",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "telegram-send"
              ]
            }
          }
        },
        {
          "name": "TikTok - Send Message",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"tiktok_user_id\",\n  \"message\": \"Hello via TikTok!\",\n  \"conversationId\": \"{{conversation_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/tiktok-send",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "tiktok-send"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Edge Functions - Search & Import",
      "item": [
        {
          "name": "Search Contacts (Edge Function)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"searchTerm\": \"John\",\n  \"tags\": [\"customer\", \"vip\"],\n  \"dealStatus\": \"open\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/search-contacts",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "search-contacts"
              ]
            },
            "description": "Advanced contact search with filtering by name, phone, email, tags, and company. Uses X-API-Key authentication. Searches across first name, last name, full name, reversed name, phone numbers, emails, tags, and company names. Returns up to 2000 results."
          }
        },
        {
          "name": "Search Companies",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"searchTerm\": \"Acme\",\n  \"country\": \"US\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/search-companies",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "search-companies"
              ]
            },
            "description": "Search companies using X-API-Key authentication."
          }
        },
        {
          "name": "Import Contacts (CSV)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"csvData\": \"First Name,Last Name,Email,Phone Number\\nJohn,Doe,john@example.com,+1234567890\",\n  \"organizationId\": \"{{organization_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/import-contacts",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "import-contacts"
              ]
            }
          }
        },
        {
          "name": "Import Companies (CSV)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"csvData\": \"Company name,Company Domain Name,Phone Number,City,Country/Region\\nAcme Inc,acme.com,+1234567890,New York,US\",\n  \"organizationId\": \"{{organization_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/import-companies",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "import-companies"
              ]
            }
          }
        },
        {
          "name": "Import Kommo Leads",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"csvData\": \"Lead data CSV\",\n  \"organizationId\": \"{{organization_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/import-kommo-leads",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "import-kommo-leads"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Edge Functions - External APIs",
      "item": [
        {
          "name": "Insert Message (External)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"phone\": \"201001383533\",\n  \"content\": \"Hello from external system!\",\n  \"direction\": \"outgoing\",\n  \"status\": \"sent\",\n  \"message_type\": \"text\",\n  \"metadata\": {},\n  \"channel_account_id\": \"{{channel_account_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/insert-message",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "insert-message"
              ]
            },
            "description": "Insert a message into ConnectGain from an external system. Uses X-API-Key header for authentication. Automatically creates or finds contacts and conversations. Reopens closed conversations if message is inbound."
          }
        },
        {
          "name": "Generate API Key",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"External System Integration\",\n  \"expires_in_days\": 365,\n  \"permissions\": {\n    \"can_send_messages\": true,\n    \"can_read_messages\": false\n  }\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/generate-api-key",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "generate-api-key"
              ]
            },
            "description": "Create a new API key for external system integration. API keys are prefixed with 'cg_' and scoped to your organization. IMPORTANT: Store the API key securely immediately after creation, as it will not be shown again."
          }
        }
      ]
    },
    {
      "name": "Edge Functions - Organization & Auth",
      "item": [
        {
          "name": "Login (Sign In)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"user@example.com\",\n  \"password\": \"your_password\"\n}"
            },
            "url": {
              "raw": "{{url}}/auth/v1/token?grant_type=password",
              "host": [
                "{{url}}"
              ],
              "path": [
                "auth",
                "v1",
                "token"
              ],
              "query": [
                {
                  "key": "grant_type",
                  "value": "password"
                }
              ]
            },
            "description": "Login to get JWT token. The response access_token is automatically saved as user_jwt_token variable by the test script. Use this token for user-authenticated endpoints like List Organizations (JWT Token), Check Subscription, etc."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "// Extract JWT token from response and save it",
                  "if (pm.response.code === 200) {",
                  "    var response = pm.response.json();",
                  "    if (response.access_token) {",
                  "        pm.collectionVariables.set('user_jwt_token', response.access_token);",
                  "        console.log('JWT token saved to user_jwt_token variable');",
                  "    }",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ]
        },
        {
          "name": "Sign Up (Register)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"newuser@example.com\",\n  \"password\": \"secure_password\",\n  \"data\": {\n    \"first_name\": \"John\",\n    \"last_name\": \"Doe\"\n  }\n}"
            },
            "url": {
              "raw": "{{url}}/auth/v1/signup",
              "host": [
                "{{url}}"
              ],
              "path": [
                "auth",
                "v1",
                "signup"
              ]
            },
            "description": "Register a new user account. User will receive email verification link."
          }
        },
        {
          "name": "Refresh Token",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"refresh_token\": \"{{refresh_token}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/auth/v1/token?grant_type=refresh_token",
              "host": [
                "{{url}}"
              ],
              "path": [
                "auth",
                "v1",
                "token"
              ],
              "query": [
                {
                  "key": "grant_type",
                  "value": "refresh_token"
                }
              ]
            },
            "description": "Refresh JWT token using refresh token"
          }
        },
        {
          "name": "Get User Info",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{user_jwt_token}}"
              }
            ],
            "url": {
              "raw": "{{url}}/auth/v1/user",
              "host": [
                "{{url}}"
              ],
              "path": [
                "auth",
                "v1",
                "user"
              ]
            },
            "description": "Get current authenticated user information"
          }
        },
        {
          "name": "Logout (Sign Out)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{user_jwt_token}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{}"
            },
            "url": {
              "raw": "{{url}}/auth/v1/logout",
              "host": [
                "{{url}}"
              ],
              "path": [
                "auth",
                "v1",
                "logout"
              ]
            },
            "description": "Logout current user and invalidate JWT token"
          }
        },
        {
          "name": "List Organizations (JWT Token)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{user_jwt_token}}",
                "description": "User JWT token - returns all organizations user has access to"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/list-organizations",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "list-organizations"
              ]
            }
          }
        },
        {
          "name": "List Organizations (X-API-Key)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}",
                "description": "API Key authentication - returns only the organization associated with this API key"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/list-organizations",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "list-organizations"
              ]
            },
            "description": "List organizations using X-API-Key authentication. Returns only the organization associated with the API key. This version works immediately with your existing api_key variable."
          }
        },
        {
          "name": "Switch Organization",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organizationId\": \"{{organization_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/switch-organization",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "switch-organization"
              ]
            }
          }
        },
        {
          "name": "Accept Invitation",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"token\": \"invitation_token\",\n  \"email\": \"user@example.com\",\n  \"password\": \"secure_password\",\n  \"first_name\": \"John\",\n  \"last_name\": \"Doe\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/accept-invitation",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "accept-invitation"
              ]
            }
          }
        },
        {
          "name": "Send Invitation Email",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"newuser@example.com\",\n  \"role\": \"AGENT\",\n  \"organizationId\": \"{{organization_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/send-invitation-email",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "send-invitation-email"
              ]
            }
          }
        },
        {
          "name": "Facebook OAuth",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{url}}/functions/v1/facebook-oauth?code=oauth_code",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "facebook-oauth"
              ],
              "query": [
                {
                  "key": "code",
                  "value": "oauth_code"
                }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Edge Functions - Payment & Subscription",
      "item": [
        {
          "name": "Create Stripe Checkout",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"priceId\": \"price_xxxxx\",\n  \"couponCode\": \"optional_coupon\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/create-checkout",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "create-checkout"
              ]
            }
          }
        },
        {
          "name": "Get Customer Portal URL",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/customer-portal",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "customer-portal"
              ]
            }
          }
        },
        {
          "name": "Check Subscription",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{user_jwt_token}}",
                "description": "Requires authenticated user JWT token (not anon key)"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/check-subscription",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "check-subscription"
              ]
            },
            "description": "Check current subscription status. Returns hasActiveSubscription, plan, and status."
          }
        }
      ]
    },
    {
      "name": "Edge Functions - Webhooks",
      "item": [
        {
          "name": "WhatsApp Lite Webhook",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"event\": \"message.received\",\n  \"data\": {}\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/whatsapp-lite-webhook",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "whatsapp-lite-webhook"
              ]
            }
          }
        },
        {
          "name": "WhatsApp Cloud Webhook",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"entry\": []\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/whatsapp-cloud-webhook",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "whatsapp-cloud-webhook"
              ]
            }
          }
        },
        {
          "name": "Messenger Webhook",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"object\": \"page\",\n  \"entry\": []\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/messenger-webhook",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "messenger-webhook"
              ]
            }
          }
        },
        {
          "name": "Instagram Webhook",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"object\": \"instagram\",\n  \"entry\": []\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/instagram-webhook",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "instagram-webhook"
              ]
            }
          }
        },
        {
          "name": "Telegram Webhook",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"update_id\": 123,\n  \"message\": {}\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/telegram-webhook",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "telegram-webhook"
              ]
            }
          }
        },
        {
          "name": "TikTok Webhook",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"event\": \"message.received\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/tiktok-webhook",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "tiktok-webhook"
              ]
            }
          }
        },
        {
          "name": "AppGain WhatsApp Webhook",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"event\": \"message\",\n  \"data\": {}\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/appgain-whatsapp-webhook",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "appgain-whatsapp-webhook"
              ]
            }
          }
        },
        {
          "name": "Stripe Webhook",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Stripe-Signature",
                "value": "signature"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"type\": \"checkout.session.completed\",\n  \"data\": {}\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/stripe-webhook",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "stripe-webhook"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "External API - X-API-Key Authentication",
      "description": "APIs that use X-API-Key header for external system integration. These endpoints are optimized for external applications and use the ConnectGain API key format (cg_xxxxxx).",
      "item": [
        {
          "name": "Search Contacts (External API)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"searchTerm\": \"John\",\n  \"tags\": [\"customer\", \"vip\"],\n  \"dealStatus\": \"open\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/search-contacts",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "search-contacts"
              ]
            },
            "description": "\u2705 WORKING - Advanced contact search for external systems. Uses X-API-Key authentication with automatic organization filtering for security."
          }
        },
        {
          "name": "Search Companies (External API)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"searchTerm\": \"Acme\",\n  \"country\": \"US\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/search-companies",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "search-companies"
              ]
            },
            "description": "Search companies using X-API-Key authentication for external systems."
          }
        },
        {
          "name": "Insert Message (External API)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"phone\": \"201001383533\",\n  \"content\": \"Hello from external system!\",\n  \"direction\": \"outgoing\",\n  \"status\": \"sent\",\n  \"message_type\": \"text\",\n  \"metadata\": {},\n  \"channel_account_id\": \"{{channel_account_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/functions/v1/insert-message",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "insert-message"
              ]
            },
            "description": "Insert a message into ConnectGain from an external system. Uses X-API-Key header for authentication. Automatically creates or finds contacts and conversations."
          }
        }
      ]
    },
    {
      "name": "REST API - Contacts",
      "item": [
        {
          "name": "List Contacts",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/contacts?select=*&organization_id=eq.{{organization_id}}&order=created_at.desc&limit=100",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "created_at.desc"
                },
                {
                  "key": "limit",
                  "value": "100"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "contacts"
              ]
            }
          }
        },
        {
          "name": "Get Single Contact",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/contacts?id=eq.{{contact_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{contact_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "contacts"
              ]
            }
          }
        },
        {
          "name": "Create Contact",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"first_name\": \"John\",\n  \"last_name\": \"Doe\",\n  \"phones\": [\"+1234567890\"],\n  \"emails\": [\"john@example.com\"],\n  \"tags\": [\"customer\", \"vip\"],\n  \"custom_fields\": {\n    \"company\": \"Acme Inc\",\n    \"position\": \"Manager\"\n  },\n  \"opt_in_status\": true\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/contacts",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "contacts"
              ]
            },
            "description": "Create a new contact. Note: May require user authentication (JWT token) if RLS policies are enabled. Ensure organization_id variable is set correctly."
          }
        },
        {
          "name": "Update Contact",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Smith\",\n  \"tags\": [\"customer\", \"vip\", \"priority\"]\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/contacts?id=eq.{{contact_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{contact_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "contacts"
              ]
            }
          }
        },
        {
          "name": "Delete Contact",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/contacts?id=eq.{{contact_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{contact_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "contacts"
              ]
            }
          }
        },
        {
          "name": "Search Contacts (REST API)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/contacts?first_name=ilike.%2AJohn%2A&organization_id=eq.{{organization_id}}",
              "query": [
                {
                  "key": "first_name",
                  "value": "ilike.%2AJohn%2A"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "contacts"
              ]
            },
            "description": "Direct REST API search using PostgREST syntax. Requires Bearer token authentication."
          }
        }
      ]
    },
    {
      "name": "REST API - Companies",
      "item": [
        {
          "name": "List Companies",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/companies?select=*&organization_id=eq.{{organization_id}}&order=name.asc",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "name.asc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "companies"
              ]
            }
          }
        },
        {
          "name": "Get Single Company",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/companies?id=eq.{{company_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{company_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "companies"
              ]
            }
          }
        },
        {
          "name": "Create Company",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"name\": \"Acme Inc\",\n  \"domain\": \"acme.com\",\n  \"email\": \"contact@acme.com\",\n  \"phone\": \"+1234567890\",\n  \"city\": \"New York\",\n  \"country\": \"US\",\n  \"industry\": \"Technology\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/companies",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "companies"
              ]
            }
          }
        },
        {
          "name": "Update Company",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Acme Corporation\",\n  \"industry\": \"Software\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/companies?id=eq.{{company_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{company_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "companies"
              ]
            }
          }
        },
        {
          "name": "Delete Company",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/companies?id=eq.{{company_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{company_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "companies"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Deals",
      "item": [
        {
          "name": "List Deals",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/deals?select=*,contacts(*),profiles%21deals_owner_id_fkey(*)&organization_id=eq.{{organization_id}}&order=created_at.desc",
              "query": [
                {
                  "key": "select",
                  "value": "*,contacts(*),profiles%21deals_owner_id_fkey(*)"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "created_at.desc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "deals"
              ]
            }
          }
        },
        {
          "name": "Get Single Deal",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/deals?id=eq.{{deal_id}}&select=*,contacts(*),profiles%21deals_owner_id_fkey(*)",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "deals"
              ],
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{deal_id}}"
                },
                {
                  "key": "select",
                  "value": "*,contacts(*),profiles%21deals_owner_id_fkey(*)"
                }
              ]
            }
          }
        },
        {
          "name": "Create Deal",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"contact_id\": \"{{contact_id}}\",\n  \"pipeline_id\": \"{{pipeline_id}}\",\n  \"title\": \"New Lead - John Doe\",\n  \"stage\": \"lead\",\n  \"value\": 5000,\n  \"probability\": 10,\n  \"expected_close_date\": \"2025-02-15\",\n  \"custom_fields\": {\n    \"source\": \"website\",\n    \"priority\": \"high\"\n  }\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/deals",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "deals"
              ]
            }
          }
        },
        {
          "name": "Update Deal",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"stage\": \"qualified\",\n  \"probability\": 50,\n  \"value\": 7500\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/deals?id=eq.{{deal_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{deal_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "deals"
              ]
            }
          }
        },
        {
          "name": "Delete Deal",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/deals?id=eq.{{deal_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{deal_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "deals"
              ]
            }
          }
        },
        {
          "name": "Filter Deals by Stage",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/deals?stage=eq.lead&organization_id=eq.{{organization_id}}",
              "query": [
                {
                  "key": "stage",
                  "value": "eq.lead"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "deals"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Pipelines",
      "item": [
        {
          "name": "List Pipelines",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/pipelines?select=*&organization_id=eq.{{organization_id}}",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "pipelines"
              ]
            }
          }
        },
        {
          "name": "Create Pipeline",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"name\": \"Sales Pipeline\",\n  \"stages\": \"[{\\\"id\\\":\\\"lead\\\",\\\"name\\\":\\\"Lead\\\"},{\\\"id\\\":\\\"qualified\\\",\\\"name\\\":\\\"Qualified\\\"}]\",\n  \"is_default\": false\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/pipelines",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "pipelines"
              ]
            }
          }
        },
        {
          "name": "Update Pipeline",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Updated Pipeline Name\",\n  \"is_default\": true\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/pipelines?id=eq.{{pipeline_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{pipeline_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "pipelines"
              ]
            }
          }
        },
        {
          "name": "Delete Pipeline",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/pipelines?id=eq.{{pipeline_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{pipeline_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "pipelines"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Conversations",
      "item": [
        {
          "name": "List Conversations",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/conversations?select=*,contacts(*),channel_accounts(*),profiles%21conversations_assignee_id_fkey(*)&organization_id=eq.{{organization_id}}&order=last_message_at.desc",
              "query": [
                {
                  "key": "select",
                  "value": "*,contacts(*),channel_accounts(*),profiles%21conversations_assignee_id_fkey(*)"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "last_message_at.desc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "conversations"
              ]
            }
          }
        },
        {
          "name": "Get Single Conversation",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/conversations?id=eq.{{conversation_id}}&select=*,contacts(*),channel_accounts(*)",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{conversation_id}}"
                },
                {
                  "key": "select",
                  "value": "*,contacts(*),channel_accounts(*)"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "conversations"
              ]
            }
          }
        },
        {
          "name": "Create Conversation",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"contact_id\": \"{{contact_id}}\",\n  \"channel_account_id\": \"{{channel_account_id}}\",\n  \"status\": \"OPEN\",\n  \"tags\": [\"urgent\", \"customer\"]\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/conversations",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "conversations"
              ]
            }
          }
        },
        {
          "name": "Update Conversation",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"status\": \"CLOSED\",\n  \"assignee_id\": \"{{user_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/conversations?id=eq.{{conversation_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{conversation_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "conversations"
              ]
            }
          }
        },
        {
          "name": "Assign Conversation",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"assignee_id\": \"{{user_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/conversations?id=eq.{{conversation_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{conversation_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "conversations"
              ]
            }
          }
        },
        {
          "name": "Delete Conversation",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/conversations?id=eq.{{conversation_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{conversation_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "conversations"
              ]
            }
          }
        },
        {
          "name": "Filter Open Conversations",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/conversations?status=eq.OPEN&organization_id=eq.{{organization_id}}",
              "query": [
                {
                  "key": "status",
                  "value": "eq.OPEN"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "conversations"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Messages",
      "item": [
        {
          "name": "List Messages",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/messages?conversation_id=eq.{{conversation_id}}&order=created_at.asc",
              "query": [
                {
                  "key": "conversation_id",
                  "value": "eq.{{conversation_id}}"
                },
                {
                  "key": "order",
                  "value": "created_at.asc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "messages"
              ]
            }
          }
        },
        {
          "name": "Get Single Message",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/messages?id=eq.{{message_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{message_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "messages"
              ]
            }
          }
        },
        {
          "name": "Create Message",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"conversation_id\": \"{{conversation_id}}\",\n  \"contact_id\": \"{{contact_id}}\",\n  \"direction\": \"OUTBOUND\",\n  \"content\": \"Hello! This is a test message.\",\n  \"status\": \"SENT\",\n  \"message_type\": \"text\",\n  \"metadata\": {\n    \"sender_name\": \"AIBot\"\n  }\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/messages",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "messages"
              ]
            }
          }
        },
        {
          "name": "Update Message",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"status\": \"DELIVERED\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/messages?id=eq.{{message_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{message_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "messages"
              ]
            }
          }
        },
        {
          "name": "Delete Message",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/messages?id=eq.{{message_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{message_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "messages"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Tasks",
      "item": [
        {
          "name": "List Tasks",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/tasks?select=*,contacts(*)&organization_id=eq.{{organization_id}}&order=due_date.asc",
              "query": [
                {
                  "key": "select",
                  "value": "*,contacts(*)"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "due_date.asc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "tasks"
              ]
            }
          }
        },
        {
          "name": "Get Single Task",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/tasks?id=eq.{{task_id}}&select=*,contacts(*)",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{task_id}}"
                },
                {
                  "key": "select",
                  "value": "*,contacts(*)"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "tasks"
              ]
            }
          }
        },
        {
          "name": "Create Task",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"contact_id\": \"{{contact_id}}\",\n  \"title\": \"Follow up with customer\",\n  \"description\": \"Call to discuss pricing\",\n  \"due_date\": \"2025-01-30T12:00:00Z\",\n  \"completed\": false,\n  \"priority\": \"HIGH\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/tasks",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "tasks"
              ]
            }
          }
        },
        {
          "name": "Update Task",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"completed\": true,\n  \"priority\": \"MEDIUM\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/tasks?id=eq.{{task_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{task_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "tasks"
              ]
            }
          }
        },
        {
          "name": "Delete Task",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/tasks?id=eq.{{task_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{task_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "tasks"
              ]
            }
          }
        },
        {
          "name": "Filter Incomplete Tasks",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/tasks?completed=eq.false&organization_id=eq.{{organization_id}}",
              "query": [
                {
                  "key": "completed",
                  "value": "eq.false"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "tasks"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Templates",
      "item": [
        {
          "name": "List Templates",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/templates?select=*&organization_id=eq.{{organization_id}}&order=created_at.desc",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "created_at.desc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "templates"
              ]
            }
          }
        },
        {
          "name": "Get Single Template",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/templates?id=eq.{{template_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{template_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "templates"
              ]
            }
          }
        },
        {
          "name": "Create Template",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"name\": \"Welcome Message\",\n  \"components\": [{\n    \"type\": \"BODY\",\n    \"text\": \"Hello {{name}}, welcome to our service!\"\n  }],\n  \"status\": \"APPROVED\",\n  \"category\": \"UTILITY\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/templates",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "templates"
              ]
            }
          }
        },
        {
          "name": "Update Template",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Updated Welcome Message\",\n  \"status\": \"APPROVED\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/templates?id=eq.{{template_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{template_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "templates"
              ]
            }
          }
        },
        {
          "name": "Delete Template",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/templates?id=eq.{{template_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{template_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "templates"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Bot Flows",
      "item": [
        {
          "name": "List Bot Flows",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/bot_flows?select=*&organization_id=eq.{{organization_id}}&order=created_at.desc",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "created_at.desc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "bot_flows"
              ]
            }
          }
        },
        {
          "name": "Get Single Bot Flow",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/bot_flows?id=eq.{{bot_flow_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{bot_flow_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "bot_flows"
              ]
            }
          }
        },
        {
          "name": "Create Bot Flow",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"name\": \"Customer Support Flow\",\n  \"description\": \"Automated customer support bot\",\n  \"nodes\": [],\n  \"edges\": [],\n  \"status\": \"DRAFT\",\n  \"version\": 1\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/bot_flows",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "bot_flows"
              ]
            }
          }
        },
        {
          "name": "Update Bot Flow",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Updated Flow Name\",\n  \"status\": \"PUBLISHED\",\n  \"nodes\": [],\n  \"edges\": []\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/bot_flows?id=eq.{{bot_flow_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{bot_flow_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "bot_flows"
              ]
            }
          }
        },
        {
          "name": "Delete Bot Flow",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/bot_flows?id=eq.{{bot_flow_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{bot_flow_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "bot_flows"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Automation Rules",
      "item": [
        {
          "name": "List Automation Rules",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/automation_rules?select=*&organization_id=eq.{{organization_id}}&order=created_at.desc",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "created_at.desc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "automation_rules"
              ]
            }
          }
        },
        {
          "name": "Get Single Automation Rule",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/automation_rules?id=eq.{{automation_rule_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{automation_rule_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "automation_rules"
              ]
            }
          }
        },
        {
          "name": "Create Automation Rule",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"name\": \"Auto Assign New Messages\",\n  \"trigger_type\": \"MESSAGE_CREATED\",\n  \"conditions\": [{\n    \"field\": \"direction\",\n    \"operator\": \"equals\",\n    \"value\": \"INBOUND\"\n  }],\n  \"actions\": [{\n    \"type\": \"ASSIGN_CONVERSATION\",\n    \"assignee_id\": \"{{user_id}}\"\n  }],\n  \"is_active\": true\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/automation_rules",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "automation_rules"
              ]
            }
          }
        },
        {
          "name": "Update Automation Rule",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"is_active\": false,\n  \"name\": \"Updated Rule Name\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/automation_rules?id=eq.{{automation_rule_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{automation_rule_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "automation_rules"
              ]
            }
          }
        },
        {
          "name": "Delete Automation Rule",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/automation_rules?id=eq.{{automation_rule_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{automation_rule_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "automation_rules"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Campaigns",
      "item": [
        {
          "name": "List Campaigns",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/campaigns?select=*&organization_id=eq.{{organization_id}}&order=created_at.desc",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "created_at.desc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "campaigns"
              ]
            }
          }
        },
        {
          "name": "Get Single Campaign",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/campaigns?id=eq.{{campaign_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{campaign_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "campaigns"
              ]
            }
          }
        },
        {
          "name": "Create Campaign",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"name\": \"New Product Launch\",\n  \"type\": \"SMS\",\n  \"content\": \"Check out our new product!\",\n  \"target_type\": \"ALL\",\n  \"status\": \"DRAFT\",\n  \"scheduled_at\": \"2025-02-01T10:00:00Z\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/campaigns",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "campaigns"
              ]
            }
          }
        },
        {
          "name": "Update Campaign",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"status\": \"SCHEDULED\",\n  \"scheduled_at\": \"2025-02-01T12:00:00Z\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/campaigns?id=eq.{{campaign_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{campaign_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "campaigns"
              ]
            }
          }
        },
        {
          "name": "Delete Campaign",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/campaigns?id=eq.{{campaign_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{campaign_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "campaigns"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Notes",
      "item": [
        {
          "name": "List Notes",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/notes?select=*&contact_id=eq.{{contact_id}}&order=created_at.desc",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "contact_id",
                  "value": "eq.{{contact_id}}"
                },
                {
                  "key": "order",
                  "value": "created_at.desc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "notes"
              ]
            }
          }
        },
        {
          "name": "Create Note",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"contact_id\": \"{{contact_id}}\",\n  \"content\": \"Customer called to inquire about pricing\",\n  \"author_id\": \"{{user_id}}\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/notes",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "notes"
              ]
            }
          }
        },
        {
          "name": "Update Note",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"content\": \"Updated note content\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/notes?id=eq.{{note_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{note_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "notes"
              ]
            }
          }
        },
        {
          "name": "Delete Note",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/notes?id=eq.{{note_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{note_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "notes"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Channel Accounts",
      "item": [
        {
          "name": "List Channel Accounts",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/channel_accounts?select=*&organization_id=eq.{{organization_id}}",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "channel_accounts"
              ]
            }
          }
        },
        {
          "name": "Get Single Channel Account",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/channel_accounts?id=eq.{{channel_account_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{channel_account_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "channel_accounts"
              ]
            }
          }
        },
        {
          "name": "Create Channel Account",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"name\": \"WhatsApp Business\",\n  \"type\": \"WHATSAPP_CLOUD\",\n  \"is_active\": true,\n  \"settings\": {\n    \"access_token\": \"token\",\n    \"phone_number_id\": \"phone_id\"\n  }\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/channel_accounts",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "channel_accounts"
              ]
            }
          }
        },
        {
          "name": "Update Channel Account",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"is_active\": false,\n  \"name\": \"Updated Channel Name\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/channel_accounts?id=eq.{{channel_account_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{channel_account_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "channel_accounts"
              ]
            }
          }
        },
        {
          "name": "Delete Channel Account",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/channel_accounts?id=eq.{{channel_account_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{channel_account_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "channel_accounts"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Projects",
      "item": [
        {
          "name": "List Projects",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/projects?select=*&organization_id=eq.{{organization_id}}&order=created_at.desc",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "order",
                  "value": "created_at.desc"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "projects"
              ]
            }
          }
        },
        {
          "name": "Get Single Project",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/projects?id=eq.{{project_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{project_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "projects"
              ]
            }
          }
        },
        {
          "name": "Create Project",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"name\": \"New Project\",\n  \"description\": \"Project description\",\n  \"status\": \"PLANNING\",\n  \"start_date\": \"2025-02-01\",\n  \"end_date\": \"2025-03-01\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/projects",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "projects"
              ]
            }
          }
        },
        {
          "name": "Update Project",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"status\": \"IN_PROGRESS\",\n  \"name\": \"Updated Project Name\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/projects?id=eq.{{project_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{project_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "projects"
              ]
            }
          }
        },
        {
          "name": "Delete Project",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/projects?id=eq.{{project_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{project_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "projects"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "REST API - Organizations & Users",
      "item": [
        {
          "name": "List Organizations",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/organizations?select=*",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "organizations"
              ]
            }
          }
        },
        {
          "name": "Get Single Organization",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/organizations?id=eq.{{organization_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{organization_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "organizations"
              ]
            }
          }
        },
        {
          "name": "Update Organization",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Updated Organization Name\",\n  \"settings\": {}\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/organizations?id=eq.{{organization_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{organization_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "organizations"
              ]
            }
          }
        },
        {
          "name": "List Profiles (Users)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/profiles?select=*&organization_id=eq.{{organization_id}}",
              "query": [
                {
                  "key": "select",
                  "value": "*"
                },
                {
                  "key": "organization_id",
                  "value": "eq.{{organization_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "profiles"
              ]
            }
          }
        },
        {
          "name": "Get Single Profile",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/profiles?id=eq.{{user_id}}&select=*",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{user_id}}"
                },
                {
                  "key": "select",
                  "value": "*"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "profiles"
              ]
            }
          }
        },
        {
          "name": "Update Profile",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Prefer",
                "value": "return=representation"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"John\",\n  \"last_name\": \"Doe\",\n  \"role\": \"ADMIN\"\n}"
            },
            "url": {
              "raw": "{{url}}/rest/v1/profiles?id=eq.{{user_id}}",
              "query": [
                {
                  "key": "id",
                  "value": "eq.{{user_id}}"
                }
              ],
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "profiles"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Edge Functions - Call Intelligence",
      "item": [
        {
          "name": "Call Recording Webhook",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/call-recording-webhook",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "call-recording-webhook"
              ]
            },
            "description": "Submit call recording from external system (PBX, VoIP). Triggers AI transcription, sentiment analysis, and action item extraction.\n\nAuthentication: X-API-Key header.\n\nRequired: external_call_id, recording_url.\nOptional: agent_identifier, customer_phone, duration_seconds, call_timestamp, direction, metadata.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"external_call_id\": \"pbx-call-12345\",\n  \"recording_url\": \"https://your-pbx.com/recordings/12345.mp3\",\n  \"agent_identifier\": \"agent@company.com\",\n  \"customer_phone\": \"+966501234567\",\n  \"duration_seconds\": 180,\n  \"call_timestamp\": \"2026-03-24T10:30:00Z\",\n  \"direction\": \"inbound\",\n  \"metadata\": {\n    \"source\": \"asterisk\",\n    \"queue\": \"sales\"\n  }\n}"
            }
          },
          "response": []
        },
        {
          "name": "Process Call Recording",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/process-call-recording",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "process-call-recording"
              ]
            },
            "description": "Trigger AI processing pipeline for a call record. Downloads audio, transcribes (Arabic/English), analyzes sentiment, generates summary, extracts action items.\n\nUsed internally after webhook/upload. Uses Google Gemini 2.5 Flash.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"call_record_id\": \"{{call_record_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Speech to Text",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/speech-to-text",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "speech-to-text"
              ]
            },
            "description": "Convert audio to text using Google Gemini. Supports Arabic and English with auto-detection.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"audio_url\": \"https://example.com/audio.mp3\",\n  \"language\": \"auto\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Translate Message",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/translate-message",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "translate-message"
              ]
            },
            "description": "Translate text between Arabic and English using Google Gemini.\n\ntargetLang: 'ar' or 'en'. Source language is auto-detected.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"text\": \"\\u0645\\u0631\\u062d\\u0628\\u0627 \\u0643\\u064a\\u0641 \\u062d\\u0627\\u0644\\u0643\",\n  \"targetLang\": \"en\",\n  \"organizationId\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Edge Functions - Mobile API",
      "item": [
        {
          "name": "Mobile - Login",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/mobile-api/login",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "mobile-api",
                "login"
              ]
            },
            "description": "Authenticate mobile app user. Returns JWT tokens and user profile.\n\nPublic endpoint - no auth header required.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"user@company.com\",\n  \"password\": \"your_password\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Mobile - List Contacts",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{user_jwt_token}}"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/mobile-api/contacts?page=1&limit=50&search=",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "mobile-api",
                "contacts?page=1&limit=50&search="
              ]
            },
            "description": "Get paginated contacts for the authenticated user's organization.\n\nQuery params: page, limit (max 200), search.\nAuth: Bearer JWT token from login."
          },
          "response": []
        },
        {
          "name": "Mobile - Get Contact",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{user_jwt_token}}"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/mobile-api/contacts/{{contact_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "mobile-api",
                "contacts",
                "{{contact_id}}"
              ]
            },
            "description": "Get single contact details with company info.\n\nAuth: Bearer JWT token."
          },
          "response": []
        },
        {
          "name": "Mobile - Upload Call Recording",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{user_jwt_token}}"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/mobile-api/call-recording",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "mobile-api",
                "call-recording"
              ]
            },
            "description": "Upload call recording from mobile app. Accepts multipart/form-data.\n\nRequired: file (audio).\nOptional: contact_id, customer_phone, duration_seconds, call_timestamp, direction, notes.\n\nMax file size: 50MB. Supported: MP3, M4A, WAV, OGG, WebM, AAC, 3GP, AMR.",
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "file",
                  "type": "file",
                  "src": "",
                  "description": "Audio recording file (max 50MB)"
                },
                {
                  "key": "contact_id",
                  "value": "{{contact_id}}",
                  "type": "text",
                  "description": "Contact UUID (optional if customer_phone provided)"
                },
                {
                  "key": "customer_phone",
                  "value": "+966501234567",
                  "type": "text",
                  "description": "Customer phone for auto-matching"
                },
                {
                  "key": "duration_seconds",
                  "value": "120",
                  "type": "text"
                },
                {
                  "key": "direction",
                  "value": "outbound",
                  "type": "text",
                  "description": "inbound or outbound"
                },
                {
                  "key": "notes",
                  "value": "Follow-up call about proposal",
                  "type": "text"
                },
                {
                  "key": "call_timestamp",
                  "value": "2026-03-24T10:30:00Z",
                  "type": "text"
                }
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Edge Functions - Lead & Deal APIs",
      "item": [
        {
          "name": "Create Lead",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/create-lead",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "create-lead"
              ]
            },
            "description": "Create a single lead (contact + optional deal) via API key.\n\nRequired: first_name or last_name.\nOptional: emails, phones, company_name, deal object, tags, source, custom_fields.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"Ahmed\",\n  \"last_name\": \"Hassan\",\n  \"emails\": [\n    \"ahmed@example.com\"\n  ],\n  \"phones\": [\n    \"+966501234567\"\n  ],\n  \"company_name\": \"Acme Corp\",\n  \"source\": \"website\",\n  \"tags\": [\n    \"hot-lead\"\n  ],\n  \"deal\": {\n    \"title\": \"Enterprise Plan\",\n    \"value\": 50000,\n    \"currency\": \"SAR\",\n    \"stage\": \"new\",\n    \"pipeline_id\": \"{{pipeline_id}}\"\n  }\n}"
            }
          },
          "response": []
        },
        {
          "name": "Create Leads Bulk",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/create-leads-bulk",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "create-leads-bulk"
              ]
            },
            "description": "Create multiple leads in a single request.\n\nAccepts array of lead objects. Max 100 per request.\nReturns per-record success/error reporting.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"leads\": [\n    {\n      \"first_name\": \"Lead 1\",\n      \"phones\": [\n        \"+966501111111\"\n      ],\n      \"source\": \"import\"\n    },\n    {\n      \"first_name\": \"Lead 2\",\n      \"emails\": [\n        \"lead2@example.com\"\n      ],\n      \"source\": \"import\"\n    }\n  ]\n}"
            }
          },
          "response": []
        },
        {
          "name": "Create Deals Bulk",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/create-deals-bulk",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "create-deals-bulk"
              ]
            },
            "description": "Create multiple deals in bulk. Auto-matches contacts by email/phone/ID.\n\nOptions: create_contact_if_missing, skip_if_exists.\nMax 100 deals per request.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"deals\": [\n    {\n      \"title\": \"Deal 1\",\n      \"value\": 10000,\n      \"currency\": \"SAR\",\n      \"stage\": \"new\",\n      \"pipeline_id\": \"{{pipeline_id}}\",\n      \"contact_email\": \"ahmed@example.com\"\n    },\n    {\n      \"title\": \"Deal 2\",\n      \"value\": 25000,\n      \"currency\": \"SAR\",\n      \"stage\": \"new\",\n      \"pipeline_id\": \"{{pipeline_id}}\",\n      \"contact_phone\": \"+966502222222\",\n      \"contact_first_name\": \"Sara\",\n      \"contact_last_name\": \"Ali\"\n    }\n  ],\n  \"create_contact_if_missing\": true,\n  \"skip_if_exists\": false\n}"
            }
          },
          "response": []
        },
        {
          "name": "Import Contacts Bulk",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-API-Key",
                "value": "{{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/import-contacts-bulk",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "import-contacts-bulk"
              ]
            },
            "description": "Bulk import contacts with merge logic. Up to 1000 records.\n\nMerges by email/phone match. Supports tags, custom_fields, company assignment.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"contacts\": [\n    {\n      \"first_name\": \"John\",\n      \"last_name\": \"Doe\",\n      \"phones\": [\n        \"+966501234567\"\n      ],\n      \"emails\": [\n        \"john@example.com\"\n      ],\n      \"tags\": [\n        \"imported\"\n      ]\n    }\n  ],\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Edge Functions - Admin APIs",
      "item": [
        {
          "name": "Admin - Get Call Token Usage",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/admin-get-call-token-usage",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "admin-get-call-token-usage"
              ]
            },
            "description": "Get AI token usage for call intelligence. Returns per-agent breakdown.\n\nAdmin/service-role auth required.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"month_year\": \"2026-03\",\n  \"include_call_details\": true\n}"
            }
          },
          "response": []
        },
        {
          "name": "Admin - Topup Call Minutes",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/admin-topup-call-minutes",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "admin-topup-call-minutes"
              ]
            },
            "description": "Allocate or top-up call recording minutes for an organization.\n\nCreates audit log entry.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"action\": \"set_monthly_limit\",\n  \"minutes\": 500,\n  \"note\": \"Monthly allocation\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Admin - Get Organizations",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/admin-get-organizations",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "admin-get-organizations"
              ]
            },
            "description": "List all organizations with analytics. Admin only.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"page\": 1,\n  \"limit\": 50\n}"
            }
          },
          "response": []
        },
        {
          "name": "Admin - Get Org Analytics",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/admin-get-org-analytics",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "admin-get-org-analytics"
              ]
            },
            "description": "Get detailed analytics for a specific organization.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Admin - Get Org Signups",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/admin-get-org-signups",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "admin-get-org-signups"
              ]
            },
            "description": "Get signup history and trends.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"days\": 30\n}"
            }
          },
          "response": []
        },
        {
          "name": "Admin - Suspend User",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/admin-suspend-user",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "admin-suspend-user"
              ]
            },
            "description": "Suspend or unsuspend a user account.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"user_id\": \"{{user_id}}\",\n  \"action\": \"suspend\",\n  \"reason\": \"Policy violation\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Admin - Delete Organization",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/admin-delete-organization",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "admin-delete-organization"
              ]
            },
            "description": "Permanently delete an organization and all data.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Admin - Get Feature Restrictions",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/admin-get-feature-restrictions",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "admin-get-feature-restrictions"
              ]
            },
            "description": "Get feature access configuration for an organization.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Admin - Update Feature Restrictions",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/admin-update-feature-restrictions",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "admin-update-feature-restrictions"
              ]
            },
            "description": "Update feature gates and restrictions for an organization.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"features\": {\n    \"call_intelligence\": true,\n    \"ai_agent\": true\n  }\n}"
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Edge Functions - Email",
      "item": [
        {
          "name": "Email - Send",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/email-send",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "email-send"
              ]
            },
            "description": "Send email via configured SMTP account.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"recipient@example.com\",\n  \"subject\": \"Test Email\",\n  \"html\": \"<p>Hello from ConnectGain</p>\",\n  \"email_account_id\": \"{{email_account_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Email - Sync",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/email-sync",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "email-sync"
              ]
            },
            "description": "Sync emails from IMAP account.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email_account_id\": \"{{email_account_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Email - Account Setup",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/email-account-setup",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "email-account-setup"
              ]
            },
            "description": "Configure IMAP/SMTP email account and test connection.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"imap_host\": \"imap.gmail.com\",\n  \"imap_port\": 993,\n  \"smtp_host\": \"smtp.gmail.com\",\n  \"smtp_port\": 587,\n  \"email\": \"account@gmail.com\",\n  \"password\": \"app_password\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Email - Delete",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/email-delete",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "email-delete"
              ]
            },
            "description": "Delete an email message.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"message_id\": \"{{message_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Email - Tracking Pixel",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{url}}/functions/v1/email-tracking-pixel?t={{tracking_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "email-tracking-pixel?t={{tracking_id}}"
              ]
            },
            "description": "1x1 transparent pixel for open tracking. Returns image. Logs open event."
          },
          "response": []
        },
        {
          "name": "Email - Tracking Redirect",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{url}}/functions/v1/email-tracking-redirect?t={{tracking_id}}&url=https://example.com",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "email-tracking-redirect?t={{tracking_id}}&url=https:",
                "",
                "example.com"
              ]
            },
            "description": "Click tracking redirect. Logs click event then redirects to target URL."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Edge Functions - AI & Bots",
      "item": [
        {
          "name": "AI Agent Respond",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/ai-agent-respond",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "ai-agent-respond"
              ]
            },
            "description": "Generate AI agent response for a conversation. Uses knowledge base and conversation context.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"conversation_id\": \"{{conversation_id}}\",\n  \"organization_id\": \"{{organization_id}}\",\n  \"message\": \"What are your business hours?\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "AI Internal Assistant",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/ai-internal-assistant",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "ai-internal-assistant"
              ]
            },
            "description": "Internal AI assistant for agents. Answers questions using knowledge base.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"message\": \"How do I handle a refund?\",\n  \"conversation_id\": \"{{ai_conversation_id}}\",\n  \"organization_id\": \"{{organization_id}}\",\n  \"channel_account_id\": \"{{channel_account_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "AI Classify Intent",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/ai-classify-intent",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "ai-classify-intent"
              ]
            },
            "description": "Classify message intent using AI.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"message\": \"I want to cancel my subscription\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Analyze Conversation",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/analyze-conversation",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "analyze-conversation"
              ]
            },
            "description": "AI analysis of conversation sentiment, topics, and suggestions.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"conversation_id\": \"{{conversation_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Bot Control",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/bot-control",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "bot-control"
              ]
            },
            "description": "Control bot flow execution - start, stop, or advance.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"action\": \"start\",\n  \"flow_id\": \"{{flow_id}}\",\n  \"conversation_id\": \"{{conversation_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Auto Tag Contacts",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/auto-tag-contacts",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "auto-tag-contacts"
              ]
            },
            "description": "AI-powered automatic contact tagging based on conversation history.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Undo Auto Tag",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/undo-auto-tag",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "undo-auto-tag"
              ]
            },
            "description": "Revert auto-tagging job by progress ID.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"progress_id\": \"{{progress_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Qdrant Rebuild",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/qdrant-rebuild",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "qdrant-rebuild"
              ]
            },
            "description": "Rebuild vector search index for AI knowledge base.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Edge Functions - n8n Integration",
      "item": [
        {
          "name": "n8n - Deploy Flow",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/n8n-deploy-flow",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "n8n-deploy-flow"
              ]
            },
            "description": "Deploy a bot flow to n8n as a webhook workflow.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"flow_id\": \"{{flow_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "n8n - Flow Callback",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/n8n-flow-callback",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "n8n-flow-callback"
              ]
            },
            "description": "Receive callback from n8n workflow execution.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"session_id\": \"{{session_id}}\",\n  \"result\": {},\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Edge Functions - Calendar & Bookings",
      "item": [
        {
          "name": "Google Calendar - OAuth URL",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/google-calendar-oauth-url",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "google-calendar-oauth-url"
              ]
            },
            "description": "Get Google OAuth URL for calendar integration.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\",\n  \"user_id\": \"{{user_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Google Calendar - Busy Times",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/google-calendar-busy-times",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "google-calendar-busy-times"
              ]
            },
            "description": "Check busy/free slots on Google Calendar.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"user_id\": \"{{user_id}}\",\n  \"start\": \"2026-03-24T00:00:00Z\",\n  \"end\": \"2026-03-25T00:00:00Z\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Google Calendar - Create Event",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/google-calendar-create-event",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "google-calendar-create-event"
              ]
            },
            "description": "Create a Google Calendar event for a booking.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"booking_id\": \"{{booking_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Send Booking Confirmation",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/send-booking-confirmation",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "send-booking-confirmation"
              ]
            },
            "description": "Send booking confirmation email to guest.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"booking_id\": \"{{booking_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Send Booking Cancellation",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/send-booking-cancellation",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "send-booking-cancellation"
              ]
            },
            "description": "Send booking cancellation email.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"booking_id\": \"{{booking_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Send Booking Reschedule",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/send-booking-reschedule",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "send-booking-reschedule"
              ]
            },
            "description": "Send booking reschedule notification.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"booking_id\": \"{{booking_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Zoom - Create Meeting",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/zoom-create-meeting",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "zoom-create-meeting"
              ]
            },
            "description": "Create a Zoom meeting for a booking.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"booking_id\": \"{{booking_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Zoom - OAuth URL",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/zoom-oauth-url",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "zoom-oauth-url"
              ]
            },
            "description": "Get Zoom OAuth URL for integration.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Edge Functions - Utilities",
      "item": [
        {
          "name": "Send Push Notification",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/send-push-notification",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "send-push-notification"
              ]
            },
            "description": "Send mobile push notification via AppGain.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"user_id\": \"{{user_id}}\",\n  \"title\": \"New Message\",\n  \"body\": \"You have a new conversation\",\n  \"data\": {\n    \"conversationId\": \"{{conversation_id}}\"\n  }\n}"
            }
          },
          "response": []
        },
        {
          "name": "Create Shared Link",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/create-shared-link",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "create-shared-link"
              ]
            },
            "description": "Create a public shared link for a resource.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"resource_type\": \"contact\",\n  \"resource_id\": \"{{contact_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Get Shared Content",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{url}}/functions/v1/get-shared-content?token={{share_token}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "get-shared-content?token={{share_token}}"
              ]
            },
            "description": "Retrieve publicly shared content by token. No auth required."
          },
          "response": []
        },
        {
          "name": "Task Automation",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/task-automation",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "task-automation"
              ]
            },
            "description": "Execute task automation rules.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"trigger_type\": \"deal_stage_change\",\n  \"trigger_data\": {\n    \"deal_id\": \"{{deal_id}}\",\n    \"new_stage\": \"won\"\n  },\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Webhook Dispatcher",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/webhook-dispatcher",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "webhook-dispatcher"
              ]
            },
            "description": "Dispatch webhook events to configured endpoints.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"event\": \"contact.created\",\n  \"data\": {},\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Check Deal SLA",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/check-deal-sla",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "check-deal-sla"
              ]
            },
            "description": "Check and update SLA status for deals.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Deal Auto Reassign",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/deal-auto-reassign",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "deal-auto-reassign"
              ]
            },
            "description": "Auto-reassign deals based on rules.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Find Duplicates",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/find-duplicates",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "find-duplicates"
              ]
            },
            "description": "Find duplicate contacts in organization.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Find Duplicate Companies",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/find-duplicate-companies",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "find-duplicate-companies"
              ]
            },
            "description": "Find duplicate companies in organization.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Cleanup Contacts",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/cleanup-contacts",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "cleanup-contacts"
              ]
            },
            "description": "Clean up orphaned or invalid contacts.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Remove Team Member",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/remove-team-member",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "remove-team-member"
              ]
            },
            "description": "Remove a team member from organization.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"user_id\": \"{{user_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Service Discovery",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/service-discovery",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "service-discovery"
              ]
            },
            "description": "List all available edge functions and their status."
          },
          "response": []
        },
        {
          "name": "Service Monitoring",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/service-monitoring",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "service-monitoring"
              ]
            },
            "description": "Health check and monitoring for services."
          },
          "response": []
        },
        {
          "name": "Token Health Check",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/token-health-check",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "token-health-check"
              ]
            },
            "description": "Verify token validity and check auth health."
          },
          "response": []
        },
        {
          "name": "Log Campaign Messages",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/log-campaign-messages",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "log-campaign-messages"
              ]
            },
            "description": "Log messages sent during a campaign.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"campaign_id\": \"{{campaign_id}}\",\n  \"messages\": [],\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Sync Subscriptions",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/sync-subscriptions",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "sync-subscriptions"
              ]
            },
            "description": "Sync subscription data from Stripe.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "WhatsApp - Fetch Templates",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/whatsapp-fetch-templates",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "whatsapp-fetch-templates"
              ]
            },
            "description": "Fetch WhatsApp message templates from Meta API.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"channel_account_id\": \"{{channel_account_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "WhatsApp - Manage Templates",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/whatsapp-manage-templates",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "whatsapp-manage-templates"
              ]
            },
            "description": "Create/update/delete WhatsApp templates on Meta.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"action\": \"create\",\n  \"channel_account_id\": \"{{channel_account_id}}\",\n  \"template\": {\n    \"name\": \"welcome\",\n    \"language\": \"en\",\n    \"components\": []\n  },\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "WhatsApp - Template Stats",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/whatsapp-template-stats",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "whatsapp-template-stats"
              ]
            },
            "description": "Get WhatsApp template usage statistics.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"channel_account_id\": \"{{channel_account_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "WhatsApp - Account Status",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/whatsapp-account-status",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "whatsapp-account-status"
              ]
            },
            "description": "Check WhatsApp account connection status.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"channel_account_id\": \"{{channel_account_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "WhatsApp - Reset",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/functions/v1/whatsapp-reset",
              "host": [
                "{{url}}"
              ],
              "path": [
                "functions",
                "v1",
                "whatsapp-reset"
              ]
            },
            "description": "Reset WhatsApp Lite connection to re-pair.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"channel_account_id\": \"{{channel_account_id}}\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "REST API - Call Records",
      "item": [
        {
          "name": "List Call Records",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_records?organization_id=eq.{{organization_id}}&order=call_timestamp.desc&limit=50",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_records?organization_id=eq.{{organization_id}}&order=call_timestamp.desc&limit=50"
              ]
            },
            "description": "List all call records for organization. Includes AI analysis results."
          },
          "response": []
        },
        {
          "name": "Get Single Call Record",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_records?id=eq.{{call_record_id}}&select=*",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_records?id=eq.{{call_record_id}}&select=*"
              ]
            },
            "description": "Get a single call record with full AI analysis data."
          },
          "response": []
        },
        {
          "name": "Update Call Record",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_records?id=eq.{{call_record_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_records?id=eq.{{call_record_id}}"
              ]
            },
            "description": "Update call record (e.g. add tags, notes).",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"tags\": [\n    \"important\",\n    \"follow-up\"\n  ],\n  \"status\": \"completed\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Delete Call Record",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_records?id=eq.{{call_record_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_records?id=eq.{{call_record_id}}"
              ]
            },
            "description": "Delete a call record."
          },
          "response": []
        }
      ]
    },
    {
      "name": "REST API - Call Events",
      "item": [
        {
          "name": "List Call Events",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_events?organization_id=eq.{{organization_id}}&order=created_at.desc&limit=50",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_events?organization_id=eq.{{organization_id}}&order=created_at.desc&limit=50"
              ]
            },
            "description": "List call events (click-to-call logs) with recording URLs."
          },
          "response": []
        },
        {
          "name": "Get Single Call Event",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_events?id=eq.{{call_event_id}}&select=*",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_events?id=eq.{{call_event_id}}&select=*"
              ]
            },
            "description": "Get a single call event."
          },
          "response": []
        },
        {
          "name": "Create Call Event",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_events",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_events"
              ]
            },
            "description": "Log a new call event.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"call_type\": \"outbound\",\n  \"caller_id\": \"{{user_id}}\",\n  \"contact_id\": \"{{contact_id}}\",\n  \"phone_number\": \"+966501234567\",\n  \"status\": \"completed\",\n  \"duration_seconds\": 120,\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Update Call Event",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_events?id=eq.{{call_event_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_events?id=eq.{{call_event_id}}"
              ]
            },
            "description": "Update call event (e.g. attach recording).",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"recording_url\": \"org_id/event_id/recording.mp3\",\n  \"recording_duration_seconds\": 60,\n  \"notes\": \"Discussed proposal\"\n}"
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "REST API - Call Minutes & Tokens",
      "item": [
        {
          "name": "Get Call Minutes Allocation",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_minutes_allocations?organization_id=eq.{{organization_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_minutes_allocations?organization_id=eq.{{organization_id}}"
              ]
            },
            "description": "Get call minutes quota for organization."
          },
          "response": []
        },
        {
          "name": "Get Call Minutes Usage",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_minutes_usage?organization_id=eq.{{organization_id}}&month_year=eq.2026-03",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_minutes_usage?organization_id=eq.{{organization_id}}&month_year=eq.2026-03"
              ]
            },
            "description": "Get per-agent call minutes usage for a month."
          },
          "response": []
        },
        {
          "name": "Get Call Token Usage",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_token_usage?organization_id=eq.{{organization_id}}&month_year=eq.2026-03",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_token_usage?organization_id=eq.{{organization_id}}&month_year=eq.2026-03"
              ]
            },
            "description": "Get AI token consumption for call intelligence."
          },
          "response": []
        },
        {
          "name": "Get Call Minutes Topup Log",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/call_minutes_topup_log?organization_id=eq.{{organization_id}}&order=created_at.desc",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "call_minutes_topup_log?organization_id=eq.{{organization_id}}&order=created_at.desc"
              ]
            },
            "description": "View audit log of minutes top-ups."
          },
          "response": []
        }
      ]
    },
    {
      "name": "REST API - AI Knowledge Base",
      "item": [
        {
          "name": "List Knowledge Base",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/ai_knowledge_base?organization_id=eq.{{organization_id}}&order=created_at.desc",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "ai_knowledge_base?organization_id=eq.{{organization_id}}&order=created_at.desc"
              ]
            },
            "description": "List AI knowledge base documents."
          },
          "response": []
        },
        {
          "name": "Create Knowledge Document",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/ai_knowledge_base",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "ai_knowledge_base"
              ]
            },
            "description": "Add a document to AI knowledge base.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"title\": \"Return Policy\",\n  \"content\": \"Our return policy allows returns within 30 days...\",\n  \"document_type\": \"policy\",\n  \"organization_id\": \"{{organization_id}}\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Update Knowledge Document",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/ai_knowledge_base?id=eq.{{document_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "ai_knowledge_base?id=eq.{{document_id}}"
              ]
            },
            "description": "Update a knowledge base document.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"content\": \"Updated content...\",\n  \"is_active\": true\n}"
            }
          },
          "response": []
        },
        {
          "name": "Delete Knowledge Document",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/ai_knowledge_base?id=eq.{{document_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "ai_knowledge_base?id=eq.{{document_id}}"
              ]
            },
            "description": "Delete a knowledge base document."
          },
          "response": []
        }
      ]
    },
    {
      "name": "REST API - Bookings & Events",
      "item": [
        {
          "name": "List Event Types",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/event_types?select=*&order=created_at.desc",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "event_types?select=*&order=created_at.desc"
              ]
            },
            "description": "List booking event types."
          },
          "response": []
        },
        {
          "name": "List Bookings",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/bookings?select=*,event_types(name)&order=start_date_time.desc&limit=50",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "bookings?select=*,event_types(name)&order=start_date_time.desc&limit=50"
              ]
            },
            "description": "List bookings with event type info."
          },
          "response": []
        },
        {
          "name": "Get Single Booking",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/bookings?id=eq.{{booking_id}}&select=*,event_types(*)",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "bookings?id=eq.{{booking_id}}&select=*,event_types(*)"
              ]
            },
            "description": "Get booking details."
          },
          "response": []
        },
        {
          "name": "List Availability Rules",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/availability_rules?event_type_id=eq.{{event_type_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "availability_rules?event_type_id=eq.{{event_type_id}}"
              ]
            },
            "description": "Get availability rules for an event type."
          },
          "response": []
        },
        {
          "name": "List Blocked Dates",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/blocked_dates?profile_id=eq.{{user_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "blocked_dates?profile_id=eq.{{user_id}}"
              ]
            },
            "description": "Get blocked dates for a user."
          },
          "response": []
        }
      ]
    },
    {
      "name": "REST API - Activity & Attendance",
      "item": [
        {
          "name": "List Contact Activity",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/contact_activity_log?contact_id=eq.{{contact_id}}&order=created_at.desc&limit=50",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "contact_activity_log?contact_id=eq.{{contact_id}}&order=created_at.desc&limit=50"
              ]
            },
            "description": "Get activity timeline for a contact."
          },
          "response": []
        },
        {
          "name": "List Attendance Logs",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/attendance_logs?organization_id=eq.{{organization_id}}&order=clock_in_at.desc",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "attendance_logs?organization_id=eq.{{organization_id}}&order=clock_in_at.desc"
              ]
            },
            "description": "Get attendance/clock-in logs."
          },
          "response": []
        },
        {
          "name": "List Availability Slots",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "apikey",
                "value": "{{anon_key}}"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{anon_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{url}}/rest/v1/availability_slots?organization_id=eq.{{organization_id}}",
              "host": [
                "{{url}}"
              ],
              "path": [
                "rest",
                "v1",
                "availability_slots?organization_id=eq.{{organization_id}}"
              ]
            },
            "description": "Get agent availability/login schedule slots."
          },
          "response": []
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "url",
      "value": "https://txpaxbxhnvnhsjwwaeoy.supabase.co",
      "description": "Base URL for ConnectGain API. Get from Supabase Dashboard \u2192 Settings \u2192 API"
    },
    {
      "key": "api_key",
      "value": "cg_your_api_key_here",
      "description": "\u2705 WORKING ConnectGain API key for external API authentication (X-API-Key header). Generate using the 'Generate API Key' endpoint. Prefixed with 'cg_'"
    },
    {
      "key": "anon_key",
      "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InR4cGF4YnhobnZuaHNqd3dhZW95Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTc1NDQyMzAsImV4cCI6MjA3MzEyMDIzMH0.T2Rj5tc6ThGKQdDUymL3vNT7miiVsjCf4QfQeS_jVNg",
      "description": "\u2705 WORKING Supabase anon key for Bearer token authentication. Get from Supabase Dashboard \u2192 Settings \u2192 API \u2192 anon public key"
    },
    {
      "key": "suit_id",
      "value": "YOUR_SUIT_ID",
      "description": "AppGain Suit ID for WhatsApp Lite"
    },
    {
      "key": "organization_id",
      "value": "YOUR_ORG_UUID",
      "description": "Your organization UUID"
    },
    {
      "key": "contact_id",
      "value": "YOUR_CONTACT_UUID",
      "description": "Contact UUID for testing"
    },
    {
      "key": "company_id",
      "value": "YOUR_COMPANY_UUID",
      "description": "Company UUID for testing"
    },
    {
      "key": "deal_id",
      "value": "YOUR_DEAL_UUID",
      "description": "Deal UUID for testing"
    },
    {
      "key": "pipeline_id",
      "value": "YOUR_PIPELINE_UUID",
      "description": "Pipeline UUID for testing"
    },
    {
      "key": "conversation_id",
      "value": "YOUR_CONVERSATION_UUID",
      "description": "Conversation UUID for testing"
    },
    {
      "key": "message_id",
      "value": "YOUR_MESSAGE_UUID",
      "description": "Message UUID for testing"
    },
    {
      "key": "task_id",
      "value": "YOUR_TASK_UUID",
      "description": "Task UUID for testing"
    },
    {
      "key": "template_id",
      "value": "YOUR_TEMPLATE_UUID",
      "description": "Template UUID for testing"
    },
    {
      "key": "bot_flow_id",
      "value": "YOUR_BOT_FLOW_UUID",
      "description": "Bot Flow UUID for testing"
    },
    {
      "key": "automation_rule_id",
      "value": "YOUR_AUTOMATION_RULE_UUID",
      "description": "Automation Rule UUID for testing"
    },
    {
      "key": "campaign_id",
      "value": "YOUR_CAMPAIGN_UUID",
      "description": "Campaign UUID for testing"
    },
    {
      "key": "note_id",
      "value": "YOUR_NOTE_UUID",
      "description": "Note UUID for testing"
    },
    {
      "key": "channel_account_id",
      "value": "YOUR_CHANNEL_ACCOUNT_UUID",
      "description": "Channel Account UUID for testing"
    },
    {
      "key": "project_id",
      "value": "YOUR_PROJECT_UUID",
      "description": "Project UUID for testing"
    },
    {
      "key": "user_id",
      "value": "YOUR_USER_UUID",
      "description": "User/Profile UUID for testing"
    },
    {
      "key": "user_jwt_token",
      "value": "YOUR_USER_JWT_TOKEN",
      "description": "Authenticated user JWT token (obtained after login). Required for user-specific endpoints like List Organizations, Check Subscription, etc. Get this from Login endpoint response or browser dev tools."
    },
    {
      "key": "refresh_token",
      "value": "YOUR_REFRESH_TOKEN",
      "description": "Refresh token for renewing JWT token when it expires. Obtained from Login endpoint response."
    },
    {
      "key": "call_record_id",
      "value": "",
      "description": "Call record UUID"
    },
    {
      "key": "email_account_id",
      "value": "",
      "description": "Email account UUID"
    },
    {
      "key": "ai_conversation_id",
      "value": "",
      "description": "AI internal conversation UUID"
    },
    {
      "key": "flow_id",
      "value": "",
      "description": "Bot flow UUID"
    },
    {
      "key": "session_id",
      "value": "",
      "description": "Bot session UUID"
    },
    {
      "key": "progress_id",
      "value": "",
      "description": "Auto-tag progress UUID"
    },
    {
      "key": "booking_id",
      "value": "",
      "description": "Booking UUID"
    },
    {
      "key": "share_token",
      "value": "",
      "description": "Shared link token"
    },
    {
      "key": "tracking_id",
      "value": "",
      "description": "Email tracking ID"
    },
    {
      "key": "document_id",
      "value": "",
      "description": "Knowledge base document UUID"
    },
    {
      "key": "call_event_id",
      "value": "",
      "description": "Call event UUID"
    }
  ]
}