{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.1",
    "title": "SEA Post Purchase Survey App - Make.com Integration API",
    "description": "REST API for SEA Post Purchase Survey App integration with Make.com automation platform.\n\n## Features\n- API Key authentication (Bearer token or X-API-Key header)\n- Real-time webhooks for instant survey response notifications\n- Connection testing and validation\n- Full error handling with sanitized messages\n- Rate limiting support\n\n## Authentication\nAll endpoints require API Key obtained from SEA Post Purchase Survey App app settings.\n\n### Getting API Key\n1. Install [SEA Post Purchase Survey App](https://apps.shopify.com/sea-survey) from Shopify App Store\n2. Go to Settings → Integrations → Make.com\n3. Click \"Generate API Key\"\n4. Copy the API key and use it in Make.com connection\n\n### Using API Key\n**Method 1 (Recommended):** Bearer Token\n```\nAuthorization: Bearer YOUR_API_KEY\n```\n\n**Method 2:** Custom Header\n```\nX-API-Key: YOUR_API_KEY\n```\n\n## Base URL\nProduction: `https://survey.avada.io/make`\n\n## Make.com Integration Patterns\n\n### Instant Trigger (New Survey Response)\n- Use webhook subscription endpoints\n- ATTACH: `POST /webhooks` - Subscribe and get `externalHookId`\n- DETACH: `DELETE /webhooks/{externalHookId}` - Unsubscribe\n- Real-time notifications when survey responses submitted\n"
  },
  "servers": [
    {
      "url": "https://survey.avada.io/make",
      "description": "Production server"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    },
    {
      "ApiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "Authentication",
      "description": "API connection validation and credential testing"
    },
    {
      "name": "Webhooks",
      "description": "Webhook subscription management for instant triggers"
    }
  ],
  "paths": {
    "/shop/status": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "Test API connection",
        "description": "Verify API key validity and test connection to SEA Post Purchase Survey App.\nReturns shop information if authentication successful.\n\n**Use Case:** Make.com connection testing\n\n**Make.com Module Type:** Connection Test\n\n**Expected Behavior:**\n- Returns 200 with shop details if API key valid\n- Returns 401 if API key invalid or missing\n- Returns 401 if API key type is not 'make'\n\n**cURL Example:**\n```bash\ncurl -X GET \"https://survey.avada.io/make/shop/status\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n```\n",
        "operationId": "testConnection",
        "x-make-module": {
          "type": "action",
          "category": "connection",
          "label": "Test Connection",
          "description": "Verify API credentials and test connection"
        },
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Connection successful",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true,
                      "description": "Indicates successful operation"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "shopId",
                        "shopName",
                        "authenticated",
                        "email"
                      ],
                      "properties": {
                        "shopId": {
                          "type": "string",
                          "description": "Shopify shop domain identifier",
                          "example": "example-shop.myshopify.com"
                        },
                        "shopName": {
                          "type": "string",
                          "description": "Human-readable shop name",
                          "example": "Example Shop"
                        },
                        "email": {
                          "type": "string",
                          "format": "email",
                          "description": "Shop owner email for connection label",
                          "example": "owner@example-shop.com"
                        },
                        "authenticated": {
                          "type": "boolean",
                          "example": true,
                          "description": "Authentication status flag"
                        }
                      }
                    },
                    "message": {
                      "type": "string",
                      "example": "API connection successful - Authentication verified",
                      "description": "Human-readable success message"
                    }
                  }
                },
                "examples": {
                  "successResponse": {
                    "summary": "Successful connection",
                    "value": {
                      "success": true,
                      "data": {
                        "shopId": "my-awesome-store.myshopify.com",
                        "shopName": "My Awesome Store",
                        "email": "owner@my-awesome-store.com",
                        "authenticated": true
                      },
                      "message": "API connection successful - Authentication verified"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/webhooks": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Subscribe webhook (ATTACH)",
        "description": "Subscribe to real-time survey response notifications.\nReturns `externalHookId` that Make.com stores for later unsubscribe.\n\n**Use Case:** Make.com instant trigger webhook subscription\n\n**Make.com Module Type:** Instant Trigger (ATTACH)\n\n**Flow:**\n1. Make.com sends POST request with webhook URL\n2. API creates subscription and returns externalHookId\n3. Make.com stores externalHookId for later DETACH\n4. When survey response submitted → webhook fires\n5. Make.com scenario runs instantly\n\n**Important:** The returned `id` field is the `externalHookId` that Make.com\nwill use in the DETACH request path: `DELETE /webhooks/{externalHookId}`\n\n**cURL Example:**\n```bash\ncurl -X POST \"https://survey.avada.io/make/webhooks\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"url\": \"https://hook.eu1.make.com/abc123xyz789\",\n    \"event\": \"response.created\"\n  }'\n```\n",
        "operationId": "subscribeWebhook",
        "x-make-module": {
          "type": "instant-trigger",
          "category": "webhook",
          "label": "New Survey Response",
          "description": "Triggers instantly when survey response submitted",
          "attach": {
            "endpoint": "POST /webhooks",
            "returns": "externalHookId"
          },
          "detach": {
            "endpoint": "DELETE /webhooks/{externalHookId}",
            "parameter": "externalHookId from attach response"
          }
        },
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Webhook subscription details",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Make.com webhook URL to receive notifications.\nFormat: https://hook.{region}.make.com/{webhook-id}\n",
                    "example": "https://hook.eu1.make.com/abc123xyz789",
                    "pattern": "^https://hook\\.(eu1|us1|us2)\\.make\\.com/[a-zA-Z0-9]+$"
                  },
                  "event": {
                    "type": "string",
                    "description": "Event type to subscribe to",
                    "default": "response.created",
                    "enum": [
                      "response.created"
                    ],
                    "example": "response.created"
                  }
                }
              },
              "examples": {
                "makeWebhook": {
                  "summary": "Make.com webhook subscription",
                  "value": {
                    "url": "https://hook.eu1.make.com/abc123xyz789",
                    "event": "response.created"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhook subscribed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "External hook ID for unsubscribe.\n**IMPORTANT:** Make.com must store this ID to use in DETACH.\n",
                          "example": "Zx7cV5bN3mQ1wE9rT2yU"
                        }
                      }
                    },
                    "message": {
                      "type": "string",
                      "example": "Webhook subscribed successfully - You will now receive real-time notifications",
                      "description": "Human-readable success message"
                    }
                  }
                },
                "examples": {
                  "successResponse": {
                    "summary": "Successful subscription",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "Zx7cV5bN3mQ1wE9rT2yU"
                      },
                      "message": "Webhook subscribed successfully - You will now receive real-time notifications"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - missing or invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missingUrl": {
                    "summary": "Missing URL",
                    "value": {
                      "success": false,
                      "error": "Webhook URL is required - Please provide a valid webhook URL in the request body"
                    }
                  },
                  "invalidUrl": {
                    "summary": "Invalid URL format",
                    "value": {
                      "success": false,
                      "error": "Invalid webhook URL format"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Unsubscribe webhook (DETACH) - Body method",
        "description": "Unsubscribe from webhook notifications using request body.\n\n**Note:** This is a backward compatibility method.\n**Recommended:** Use `DELETE /webhooks/{externalHookId}` instead.\n\n**cURL Example:**\n```bash\ncurl -X DELETE \"https://survey.avada.io/make/webhooks\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"externalHookId\": \"Zx7cV5bN3mQ1wE9rT2yU\"\n  }'\n```\n",
        "operationId": "unsubscribeWebhookBody",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "externalHookId": {
                    "type": "string",
                    "description": "External hook ID from subscribe response",
                    "example": "Zx7cV5bN3mQ1wE9rT2yU"
                  },
                  "targetUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "Target URL (backward compatibility only)",
                    "example": "https://hook.eu1.make.com/abc123xyz789"
                  }
                }
              },
              "examples": {
                "withExternalHookId": {
                  "summary": "Unsubscribe by externalHookId",
                  "value": {
                    "externalHookId": "Zx7cV5bN3mQ1wE9rT2yU"
                  }
                },
                "withTargetUrl": {
                  "summary": "Unsubscribe by targetUrl (legacy)",
                  "value": {
                    "targetUrl": "https://hook.eu1.make.com/abc123xyz789"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhook unsubscribed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Webhook unsubscribed successfully"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - missing required fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missingParams": {
                    "summary": "Missing parameters",
                    "value": {
                      "success": false,
                      "error": "externalHookId or targetUrl is required"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/webhooks/{externalHookId}": {
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Unsubscribe webhook (DETACH) - Recommended",
        "description": "Unsubscribe from webhook notifications using URL path parameter.\n\n**This is the Make.com standard method (RECOMMENDED)**\n\n**Use Case:** Make.com instant trigger webhook unsubscribe\n\n**Make.com Module Type:** Instant Trigger (DETACH)\n\n**Flow:**\n1. User deactivates scenario or deletes instant trigger\n2. Make.com sends DELETE request with externalHookId in path\n3. API deletes webhook subscription\n4. No more notifications sent to Make.com\n\n**cURL Example:**\n```bash\ncurl -X DELETE \"https://survey.avada.io/make/webhooks/Zx7cV5bN3mQ1wE9rT2yU\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n```\n",
        "operationId": "unsubscribeWebhook",
        "x-make-module": {
          "type": "instant-trigger",
          "category": "webhook",
          "operation": "detach",
          "label": "Unsubscribe Webhook",
          "description": "Remove webhook subscription when scenario deactivated"
        },
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "externalHookId",
            "in": "path",
            "required": true,
            "description": "External hook ID returned from subscribe (ATTACH) response — a Firestore document ID. Make.com automatically provides this from stored subscription data.",
            "schema": {
              "type": "string"
            },
            "example": "Zx7cV5bN3mQ1wE9rT2yU"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook unsubscribed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Webhook unsubscribed successfully - You will no longer receive notifications"
                    }
                  }
                },
                "examples": {
                  "successResponse": {
                    "summary": "Successful unsubscribe",
                    "value": {
                      "success": true,
                      "message": "Webhook unsubscribed successfully - You will no longer receive notifications"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid externalHookId",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalidId": {
                    "summary": "Invalid externalHookId",
                    "value": {
                      "success": false,
                      "error": "Webhook ID or URL is required - Please provide externalHookId or targetUrl"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "404": {
            "description": "Webhook subscription not found (unknown ID, already deleted, or owned by a different shop)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "notFound": {
                    "summary": "Subscription not found",
                    "value": {
                      "success": false,
                      "error": "Webhook subscription not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/webhooks/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Test webhook delivery",
        "description": "Send a sample payload to webhook URL for testing integration.\nUseful during Make.com scenario development and testing.\n\n**Use Case:** Test webhook delivery before going live\n\n**Make.com Module Type:** Action (Testing)\n\n**Sample Payload Sent:**\n```json\n{\n  \"id\": \"response_123\",\n  \"surveyId\": \"survey_456\",\n  \"customerEmail\": \"test@example.com\",\n  \"answers\": [\n    {\n      \"questionId\": \"q1\",\n      \"question\": \"Are you satisfied with the product?\",\n      \"answer\": \"Yes\",\n      \"answerType\": \"single_choice\"\n    }\n  ],\n  \"createdAt\": \"2025-12-23T08:30:00.000Z\",\n  \"status\": \"completed\"\n}\n```\n\n**cURL Example:**\n```bash\ncurl -X POST \"https://survey.avada.io/make/webhooks/test\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"targetUrl\": \"https://hook.eu1.make.com/abc123xyz789\"\n  }'\n```\n",
        "operationId": "testWebhook",
        "x-make-module": {
          "type": "action",
          "category": "testing",
          "label": "Test Webhook",
          "description": "Send test payload to webhook URL"
        },
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Webhook URL to test",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "targetUrl"
                ],
                "properties": {
                  "targetUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "Webhook URL to send test payload to",
                    "example": "https://hook.eu1.make.com/abc123xyz789",
                    "pattern": "^https://hook\\.(eu1|us1|us2)\\.make\\.com/[a-zA-Z0-9]+$"
                  }
                }
              },
              "examples": {
                "testWebhook": {
                  "summary": "Test webhook URL",
                  "value": {
                    "targetUrl": "https://hook.eu1.make.com/abc123xyz789"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Test webhook sent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Whether test payload was sent successfully",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Test webhook sent successfully - Check your Make.com scenario for the sample payload"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Test successful",
                    "value": {
                      "success": true,
                      "message": "Test webhook sent successfully - Check your Make.com scenario for the sample payload"
                    }
                  },
                  "failure": {
                    "summary": "Test failed",
                    "value": {
                      "success": false,
                      "message": "Test webhook delivery failed - Please verify the webhook URL is correct"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - missing or invalid targetUrl",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missingUrl": {
                    "summary": "Missing targetUrl",
                    "value": {
                      "success": false,
                      "error": "Webhook URL is required - Please provide targetUrl in the request body"
                    }
                  },
                  "invalidUrl": {
                    "summary": "Invalid URL format",
                    "value": {
                      "success": false,
                      "error": "Invalid webhook URL format"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API_KEY",
        "description": "API Key authentication using Bearer token (Recommended).\n\n**Header Format:**\n```\nAuthorization: Bearer YOUR_API_KEY\n```\n\n**Example:**\n```\nAuthorization: Bearer ak_1234567890abcdef\n```\n\n**How to Get API Key:**\n1. Install [SEA Post Purchase Survey App](https://apps.shopify.com/sea-survey) from Shopify App Store\n2. Navigate to Settings → Integrations → Make.com\n3. Click \"Generate API Key\"\n4. Copy and securely store the key\n"
      },
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "API Key authentication using custom header (Alternative method).\n\n**Header Format:**\n```\nX-API-Key: YOUR_API_KEY\n```\n\n**Example:**\n```\nX-API-Key: ak_1234567890abcdef\n```\n\n**Note:** Bearer token method is recommended for better compatibility.\n"
      }
    },
    "schemas": {
      "WebhookPayload": {
        "type": "object",
        "description": "Webhook payload sent to Make.com when survey response is submitted.\nThis is the real-time data sent to instant triggers.\n",
        "required": [
          "id",
          "surveyId",
          "surveyTitle",
          "answers",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique response identifier (Firestore document ID)",
            "example": "aB3dE5fG7hI9jK1LmN0p"
          },
          "surveyId": {
            "type": "string",
            "description": "Survey identifier",
            "example": "Qw8rT2yU4iO6pA1sD3fG"
          },
          "surveyTitle": {
            "type": "string",
            "description": "Survey name",
            "example": "Post Purchase Satisfaction Survey"
          },
          "surveyType": {
            "type": "string",
            "description": "Survey type (e.g. 'survey', 'surveyForm')",
            "example": "survey"
          },
          "customerId": {
            "type": "string",
            "description": "Shopify customer ID",
            "example": "6789012345",
            "nullable": true
          },
          "customerEmail": {
            "type": "string",
            "format": "email",
            "description": "Customer email address",
            "example": "customer@example.com",
            "nullable": true
          },
          "customerName": {
            "type": "string",
            "description": "Customer full name",
            "example": "Jane Smith",
            "nullable": true
          },
          "answers": {
            "type": "array",
            "description": "Array of question-answer pairs",
            "items": {
              "$ref": "#/components/schemas/Answer"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Response creation timestamp (ISO 8601 format)",
            "example": "2025-12-23T08:30:45.123Z"
          },
          "channelType": {
            "type": "string",
            "description": "Survey distribution channel",
            "enum": [
              "dedicatedPageSurvey",
              "siteWidget",
              "postPurchasePage",
              "exitIntent",
              "postPurchaseEmail",
              "hyperLink",
              "embedSurvey",
              "embedEmail",
              "surveyForm"
            ],
            "example": "postPurchasePage",
            "nullable": true
          }
        }
      },
      "Answer": {
        "type": "object",
        "description": "Question-answer pair representing one survey question response",
        "required": [
          "question",
          "answer"
        ],
        "properties": {
          "question": {
            "type": "string",
            "description": "Question text as shown to customer",
            "example": "How would you rate your experience?",
            "minLength": 1
          },
          "answer": {
            "description": "Answer value as string. Multiple-choice answers are joined with \", \" (e.g. \"Option A, Option B\"). Null when the question was skipped.",
            "example": "Very satisfied",
            "type": "string",
            "nullable": true
          },
          "answerType": {
            "type": "string",
            "description": "Question type that determines answer format",
            "enum": [
              "single",
              "multiple",
              "number_scale",
              "star_rating",
              "satisfaction",
              "short_answer",
              "date",
              "consent_email",
              "text_image",
              "email",
              "upload"
            ],
            "example": "single"
          }
        },
        "example": {
          "question": "How satisfied are you with your purchase?",
          "answer": "Very satisfied",
          "answerType": "single"
        }
      },
      "Error": {
        "type": "object",
        "description": "Standard error response format",
        "required": [
          "success",
          "error"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "example": false,
            "description": "Always false for error responses"
          },
          "error": {
            "type": "string",
            "description": "Clear, actionable error message explaining what went wrong",
            "example": "Authentication failed - Shop not identified. Please check your API key.",
            "minLength": 1
          },
          "details": {
            "type": "string",
            "description": "Optional technical details about the error (for debugging)",
            "example": "TypeError - Cannot read property 'shopId' of undefined"
          }
        },
        "example": {
          "success": false,
          "error": "Authentication failed - Shop not identified. Please check your API key."
        }
      }
    },
    "responses": {
      "UnauthorizedError": {
        "description": "Unauthorized - Invalid, missing, or wrong type of API key.\n\n**Common Causes:**\n- API key not provided in request headers\n- API key is invalid or expired\n- API key is not of type 'make'\n- API key has been revoked\n\n**Resolution:**\n1. Verify API key is correct\n2. Ensure using Bearer token or X-API-Key header\n3. Check API key has 'make' type (not 'zapier' or other)\n4. Regenerate API key if expired\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "missingApiKey": {
                "summary": "API key not provided",
                "value": {
                  "success": false,
                  "error": "Authentication failed - API Key is required. Please provide it in Authorization header."
                }
              },
              "invalidApiKey": {
                "summary": "API key invalid",
                "value": {
                  "success": false,
                  "error": "Authentication failed - Invalid API Key. Please check your credentials."
                }
              },
              "wrongKeyType": {
                "summary": "Wrong API key type",
                "value": {
                  "success": false,
                  "error": "Authentication failed - This endpoint requires a Make.com API key, not a Zapier key."
                }
              }
            }
          }
        }
      },
      "InternalServerError": {
        "description": "Internal server error - Something went wrong on the server.\n\n**Common Causes:**\n- Database connection issues\n- Unexpected data format\n- Third-party service unavailable\n\n**Resolution:**\n- Retry request after a few seconds\n- Check system status page\n- Contact support if error persists\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "genericError": {
                "summary": "Generic server error",
                "value": {
                  "success": false,
                  "error": "Connection test failed - Unable to verify authentication",
                  "details": "Internal server error occurred"
                }
              },
              "databaseError": {
                "summary": "Database error",
                "value": {
                  "success": false,
                  "error": "Webhook subscription failed - Unable to register webhook URL",
                  "details": "Database connection timeout after 5000ms"
                }
              }
            }
          }
        }
      }
    },
    "examples": {
      "FullWebhookPayload": {
        "summary": "Complete webhook notification payload",
        "value": {
          "id": "aB3dE5fG7hI9jK1LmN0p",
          "surveyId": "Qw8rT2yU4iO6pA1sD3fG",
          "surveyTitle": "Post Purchase Satisfaction Survey",
          "customerId": "6789012345",
          "customerEmail": "jane.smith@example.com",
          "customerName": "Jane Smith",
          "answers": [
            {
              "question": "How satisfied are you with your purchase?",
              "answer": "Extremely satisfied",
              "answerType": "single"
            },
            {
              "question": "Product quality rating",
              "answer": "5",
              "answerType": "star_rating"
            },
            {
              "question": "Any additional comments?",
              "answer": "Love the product! Will definitely buy again.",
              "answerType": "short_answer"
            },
            {
              "question": "Subscribe to newsletter?",
              "answer": true,
              "answerType": "consent_email"
            }
          ],
          "createdAt": "2025-12-23T15:30:45.678Z",
          "channelType": "postPurchasePage",
          "surveyType": "survey"
        }
      }
    }
  },
  "x-make-integration": {
    "version": "1.0.1",
    "appName": "SEA Post Purchase Survey App",
    "appCategory": "Marketing & CRM",
    "supportedRegions": [
      "eu1",
      "us1",
      "us2"
    ],
    "modules": [
      {
        "name": "testConnection",
        "type": "action",
        "category": "connection",
        "visible": true
      },
      {
        "name": "newSurveyResponse",
        "type": "instant-trigger",
        "category": "webhook",
        "visible": true,
        "attach": "subscribeWebhook",
        "detach": "unsubscribeWebhook"
      },
      {
        "name": "testWebhook",
        "type": "action",
        "category": "testing",
        "visible": true
      }
    ],
    "connection": {
      "type": "apiKey",
      "authType": "bearer",
      "testEndpoint": "/shop/status",
      "fields": [
        {
          "name": "apiKey",
          "type": "text",
          "label": "API Key",
          "required": true,
          "help": "Install [SEA Post Purchase Survey App](https://apps.shopify.com/sea-survey) then get API key from Settings → Integrations → Make.com"
        }
      ]
    }
  }
}
