{
  "info": {
    "name": "Rasa.io API Collection",
    "description": "Complete collection for Rasa.io API including authentication, person management, and analytics endpoints",
    "version": "1.0.0",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "noauth"
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          ""
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://api.rasa.io/v1",
      "type": "string"
    },
    {
      "key": "rasaToken",
      "value": "",
      "type": "string"
    },
    {
      "key": "basicAuth",
      "value": "",
      "type": "string",
      "description": "Base64 encoded username:password for basic auth"
    },
    {
      "key": "communityKey",
      "value": "",
      "type": "string",
      "description": "Your community API key UUID"
    }
  ],
  "item": [
    {
      "name": "Authentication",
      "item": [
        {
          "name": "Create Token",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201) {",
                  "    const response = pm.response.json();",
                  "    if (response.results && response.results.length > 0) {",
                  "        pm.collectionVariables.set('rasaToken', response.results[0].token);",
                  "        console.log('Token saved to collection variable');",
                  "    }",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "auth": {
              "type": "basic",
              "basic": [
                {
                  "key": "username",
                  "value": "{{username}}",
                  "type": "string"
                },
                {
                  "key": "password",
                  "value": "{{password}}",
                  "type": "string"
                }
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"key\": \"{{communityKey}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/tokens",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "tokens"
              ]
            },
            "description": "Creates a new API token using basic authentication and community key. The token will be automatically saved to the collection variable for use in other requests."
          }
        },
        {
          "name": "Delete All Tokens",
          "request": {
            "method": "DELETE",
            "auth": {
              "type": "basic",
              "basic": [
                {
                  "key": "username",
                  "value": "{{username}}",
                  "type": "string"
                },
                {
                  "key": "password",
                  "value": "{{password}}",
                  "type": "string"
                }
              ]
            },
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/tokens",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "tokens"
              ]
            },
            "description": "Deletes all tokens associated with the authenticated user."
          }
        },
        {
          "name": "Delete Specific Token",
          "request": {
            "method": "DELETE",
            "auth": {
              "type": "basic",
              "basic": [
                {
                  "key": "username",
                  "value": "{{username}}",
                  "type": "string"
                },
                {
                  "key": "password",
                  "value": "{{password}}",
                  "type": "string"
                }
              ]
            },
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/tokens/{{rasaToken}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "tokens",
                "{{rasaToken}}"
              ]
            },
            "description": "Deletes a specific token by token value."
          }
        }
      ],
      "description": "Authentication endpoints for managing API tokens"
    },
    {
      "name": "Persons",
      "item": [
        {
          "name": "Search Persons",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/persons?email=john.doe@example.com&limit=10",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "persons"
              ],
              "query": [
                {
                  "key": "email",
                  "value": "john.doe@example.com",
                  "description": "Filter by email address"
                },
                {
                  "key": "limit",
                  "value": "10",
                  "description": "Maximum number of results"
                },
                {
                  "key": "first_name",
                  "value": "John",
                  "disabled": true,
                  "description": "Filter by first name"
                },
                {
                  "key": "last_name",
                  "value": "Doe",
                  "disabled": true,
                  "description": "Filter by last name"
                },
                {
                  "key": "external_id",
                  "value": "ext123",
                  "disabled": true,
                  "description": "Filter by external ID"
                },
                {
                  "key": "is_active",
                  "value": "1",
                  "disabled": true,
                  "description": "Filter by active status (1 for active, 0 for inactive)"
                },
                {
                  "key": "is_subscribed",
                  "value": "1",
                  "disabled": true,
                  "description": "Filter by subscription status"
                }
              ]
            },
            "description": "Search for persons using various filters like email, name, external ID, etc."
          }
        },
        {
          "name": "Get Person by ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/persons/d290f1ee-6c54-4b01-90e6-d701748f0851",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "persons",
                "d290f1ee-6c54-4b01-90e6-d701748f0851"
              ]
            },
            "description": "Retrieve a specific person by their ID."
          }
        },
        {
          "name": "Create/Update Persons",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "[\n  {\n    \"identifier\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n    \"email\": \"john.doe@example.com\",\n    \"first_name\": \"John\",\n    \"last_name\": \"Doe\",\n    \"is_active\": 1,\n    \"is_subscribed\": 1,\n    \"external_id\": \"customer_123\",\n    \"custom_attributes\": {\n      \"company\": \"Acme Corp\",\n      \"industry\": \"Technology\"\n    }\n  }\n]",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/persons",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "persons"
              ]
            },
            "description": "Create or update person records. Accepts an array of person objects."
          }
        },
        {
          "name": "Update Person",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"Jane\",\n  \"last_name\": \"Smith\",\n  \"is_active\": 1,\n  \"custom_attributes\": {\n    \"job_title\": \"Marketing Manager\",\n    \"department\": \"Marketing\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/persons/d290f1ee-6c54-4b01-90e6-d701748f0851",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "persons",
                "d290f1ee-6c54-4b01-90e6-d701748f0851"
              ]
            },
            "description": "Update a specific person's information."
          }
        },
        {
          "name": "Get Person Actions",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/persons/d290f1ee-6c54-4b01-90e6-d701748f0851/actions?start_date=2024-01-01&end_date=2024-12-31",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "persons",
                "d290f1ee-6c54-4b01-90e6-d701748f0851",
                "actions"
              ],
              "query": [
                {
                  "key": "start_date",
                  "value": "2024-01-01",
                  "description": "Start date for action history"
                },
                {
                  "key": "end_date",
                  "value": "2024-12-31",
                  "description": "End date for action history"
                },
                {
                  "key": "limit",
                  "value": "100",
                  "disabled": true,
                  "description": "Maximum number of actions to return"
                }
              ]
            },
            "description": "Get action history for a specific person (opens, clicks, etc.)."
          }
        },
        {
          "name": "Get Person Topics",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/persons/d290f1ee-6c54-4b01-90e6-d701748f0851/topics",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "persons",
                "d290f1ee-6c54-4b01-90e6-d701748f0851",
                "topics"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "50",
                  "disabled": true,
                  "description": "Maximum number of topics to return"
                }
              ]
            },
            "description": "Get topic interests and engagement for a specific person."
          }
        },
        {
          "name": "Get Person Attributes",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/persons/d290f1ee-6c54-4b01-90e6-d701748f0851/attributes",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "persons",
                "d290f1ee-6c54-4b01-90e6-d701748f0851",
                "attributes"
              ]
            },
            "description": "Get custom attributes for a specific person."
          }
        }
      ],
      "description": "Person management endpoints for searching, creating, updating, and retrieving person data"
    },
    {
      "name": "Analytics",
      "item": [
        {
          "name": "Activities Analytics",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"date_range\": \"past_week\",\n  \"interval\": \"day\",\n  \"metrics\": [\"open\", \"click\", \"delivered\", \"bounce\"],\n  \"suspect_click\": \"real_clicks\",\n  \"timezone\": \"US/Central\",\n  \"segment_code\": \"All\",\n  \"limit\": 100\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/analytics/activities",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "analytics",
                "activities"
              ]
            },
            "description": "Get email activity analytics with date histogram aggregations. Returns opens, clicks, deliveries, and bounces over time."
          }
        },
        {
          "name": "Activities Analytics - Custom Date Range",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"date_range\": {\n    \"start_date\": \"2024-01-01T00:00:00Z\",\n    \"end_date\": \"2024-01-31T23:59:59Z\"\n  },\n  \"interval\": \"week\",\n  \"metrics\": [\"open\", \"click\"],\n  \"suspect_click\": \"all_clicks\",\n  \"timezone\": \"America/New_York\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/analytics/activities",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "analytics",
                "activities"
              ]
            },
            "description": "Get activity analytics with custom date range and weekly aggregation."
          }
        },
        {
          "name": "Articles Analytics",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"date_range\": \"past_month\",\n  \"suspect_click\": \"real_clicks\",\n  \"segment_code\": \"All\",\n  \"limit\": 25,\n  \"timezone\": \"US/Pacific\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/analytics/articles",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "analytics",
                "articles"
              ]
            },
            "description": "Get article click analytics ranked by popularity. Returns article details with click metrics."
          }
        },
        {
          "name": "Topics Analytics",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "rasa-token",
                "value": "{{rasaToken}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"date_range\": \"past_week\",\n  \"suspect_click\": \"real_clicks\",\n  \"segment_code\": \"All\",\n  \"limit\": 50,\n  \"timezone\": \"US/Central\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/analytics/topics",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "analytics",
                "topics"
              ]
            },
            "description": "Get topic engagement analytics. Returns topics ranked by total interactions with unique user engagement metrics."
          }
        }
      ],
      "description": "Analytics endpoints for activity, article, and topic reporting"
    }
  ]
}