### Example API Request Headers (JSON) Source: https://docs.trypopcorn.ai/tools/tool-configuration Demonstrates common headers used in API requests, such as Content-Type and Authorization. These are crucial for specifying the request format and providing authentication credentials. ```json { "Content-Type": "application/json", "Authorization": "Bearer YOUR_API_KEY" } ``` -------------------------------- ### GET /template/ Source: https://docs.trypopcorn.ai/api-reference/templates/get Retrieves a list of templates available for an organization. Requires an API key for authentication. ```APIDOC ## GET /template/ ### Description Endpoint to retrieve a list of templates for an organization. ### Method GET ### Endpoint https://api.trypopcorn.ai/template/ ### Parameters #### Headers - **POPCORN-API-KEY** (string) - Required - API key provided by the Popcorn team. ### Request Example ```http GET https://api.trypopcorn.ai/template/ POPCORN-API-KEY: your_popcorn_api_key ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the template data. - **templates** (array) - A list of template objects. - **id** (string) - The unique identifier for the template. - **metaTemplateName** (string) - The name of the template. - **metaTemplateCategory** (string) - The category of the template. - **metaTemplateType** (string) - The type of the template. - **metaTemplateLanguage** (string) - The language of the template. - **metaTemplateComponents** (array) - List of components in the template. - **metaTemplateMetaId** (string) - The meta ID of the template. - **metaTemplateMetaStatus** (string) - The status of the template. - **createdAt** (string) - The creation timestamp of the template. - **updatedAt** (string) - The last update timestamp of the template. - **count** (integer) - The total number of templates returned. #### Response Example ```json { "success": true, "data": { "templates": [ { "id": "12345", "metaTemplateName": "Welcome Template", "metaTemplateCategory": "Greeting", "metaTemplateType": "Text", "metaTemplateLanguage": "EN", "metaTemplateComponents": ["text"], "metaTemplateMetaId": "meta_12345", "metaTemplateMetaStatus": "active", "createdAt": "2023-10-10T10:00:00Z", "updatedAt": "2023-10-10T10:00:00Z" } ], "count": 1 } } ``` #### Error Response - **success** (boolean) - Indicates if the request was successful. - **error** (string) - A message describing the error. - **details** (string) - Additional details about the error. #### Error Response Example ```json { "success": false, "error": "Failed to fetch templates", "details": "Database connection error" } ``` ### Errors - 500 - Internal server error, failed to fetch templates. ``` -------------------------------- ### API Example for Dynamic URL Button Values Source: https://docs.trypopcorn.ai/essentials/templates/dynamic-url-buttons This example demonstrates how to send dynamic URL parameter values to the Popcorn.ai API when sending a template. The `buttonValues` object maps the button text to the desired parameter value. ```http POST https://api.trypopcorn.ai/template/:templateId Content-Type: application/json POPCORN-API-KEY: your_popcorn_api_key { "recipientNumber": "1234567890", "buttonValues": { "Learn More": "pricing" } } ``` -------------------------------- ### Example API Response for Templates (JSON) Source: https://docs.trypopcorn.ai/api-reference/templates/get This JSON structure represents a successful response from the Popcorn AI API when fetching templates. It includes a 'success' flag, 'data' object with a list of 'templates' and their 'count', and metadata for each template. ```json { "success": true, "data": { "templates": [ { "id": "12345", "metaTemplateName": "Welcome Template", "metaTemplateCategory": "Greeting", "metaTemplateType": "Text", "metaTemplateLanguage": "EN", "metaTemplateComponents": ["text"], "metaTemplateMetaId": "meta_12345", "metaTemplateMetaStatus": "active", "createdAt": "2023-10-10T10:00:00Z", "updatedAt": "2023-10-10T10:00:00Z" } ], "count": 1 } } ``` -------------------------------- ### API Authentication Header Example Source: https://docs.trypopcorn.ai/api-reference/introduction Demonstrates the required HTTP header for authenticating requests to the Popcorn API. The POPCORN-API-KEY must be included in every request to authorize access. ```http POPCORN-API-KEY: your_popcorn_api_key ``` -------------------------------- ### Get Organization Templates (HTTP) Source: https://docs.trypopcorn.ai/api-reference/templates/get This snippet demonstrates how to make an HTTP GET request to the Popcorn AI API to retrieve a list of templates for an organization. It requires an API key in the headers. The response will be a JSON object containing a list of templates or an error message. ```http GET https://api.trypopcorn.ai/template/ POPCORN-API-KEY: your_popcorn_api_key ``` -------------------------------- ### Common Dynamic URL Patterns Source: https://docs.trypopcorn.ai/essentials/templates/dynamic-url-buttons Examples of common patterns for dynamic URLs used in product pages, user-specific pages, and for UTM tracking. These illustrate how placeholders can be used to create personalized or trackable links. ```plaintext https://store.com/{{1}} Where {{1}} could be: shoes, electronics, sale ``` ```plaintext https://app.com/onboarding/{{1}} Where {{1}} could be: step1, business, personal ``` ```plaintext https://yoursite.com/landing?utm_campaign={{1}} Where {{1}} could be: spring_sale, welcome_offer, follow_up ```