{
  "openapi": "3.0.0",
  "info": {
    "title": "Raw Data Exports API",
    "version": "1.7.1",
    "description": "# Raw Data Exports API\n<p>Access and manage your data exports through the API.</p>\n<p>The API is available to authenticated users with an access token that can be generated\n  <a\n    href='https://dashboard.tenjin.com/dashboard/access_tokens'\n    title='Tenjin Access Tokens'\n  >\n    here\n  </a>.\n</p>\n"
  },
  "servers": [
    {
      "url": "https://api.tenjin.com/data_exports"
    }
  ],
  "tags": [
    {
      "name": "Raw Data Exports",
      "description": "Create, list, and download data exports"
    },
    {
      "name": "Apps",
      "description": "Look up app details by ID"
    },
    {
      "name": "Ad Networks",
      "description": "Look up ad network details by ID"
    },
    {
      "name": "Event type groups",
      "description": "List available event type groups for filtering exports"
    }
  ],
  "paths": {
    "/v1/exports": {
      "get": {
        "operationId": "get_exports",
        "summary": "List all data exports",
        "description": "Results are paginated and ordered newest first. Use the `page` and `per_page` query parameters to page through results; pagination metadata is returned in the response headers.",
        "deprecated": false,
        "tags": [
          "Raw Data Exports"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "Page of results to fetch.",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "description": "Number of results to return per page.",
            "schema": {
              "type": "integer",
              "default": 25,
              "minimum": 0,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get all data exports for the current user",
            "headers": {
              "Link": {
                "schema": {
                  "type": "string"
                },
                "description": "RFC 8288 pagination links (rel=\"first\", \"last\", \"next\", \"prev\")"
              },
              "Total": {
                "schema": {
                  "type": "integer"
                },
                "description": "Total number of exports matching the request"
              },
              "Per-Page": {
                "schema": {
                  "type": "integer"
                },
                "description": "Number of exports returned per page"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DataExport"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Forbidden - Missing or invalid authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Unauthorized - Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Invalid pagination parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_exports",
        "summary": "Create a new data export",
        "description": "Create a new data export",
        "deprecated": false,
        "tags": [
          "Raw Data Exports"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/post_exports_Request"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Create a new data export",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataExport"
                }
              }
            }
          },
          "401": {
            "description": "Forbidden - Missing or invalid authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Unauthorized - Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Wrong Params",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Open-export limit or daily ending-today limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Raw data exports are temporarily paused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/exports/{id}": {
      "get": {
        "operationId": "get_exports_id",
        "summary": "Get a specific data export",
        "description": "Get details of a specific data export",
        "deprecated": false,
        "tags": [
          "Raw Data Exports"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Data export ID (UUID)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get details of a specific data export",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataExport"
                }
              }
            }
          },
          "401": {
            "description": "Forbidden - Missing or invalid authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Unauthorized - Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/exports/{id}/files/{encoded_uri}/download": {
      "get": {
        "operationId": "get_exports_id_files_encoded_uri_download",
        "summary": "Download an export file",
        "description": "Download a specific file from a data export (returns 303 redirect to presigned S3 URL)",
        "deprecated": false,
        "tags": [
          "Raw Data Exports"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Data export ID (UUID)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "encoded_uri",
            "in": "path",
            "required": true,
            "description": "Base64url-encoded S3 URI",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "303": {
            "description": "Redirect to presigned S3 download URL",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Forbidden - Missing or invalid authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Unauthorized - Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not Found or completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "Gone - Export expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable - S3 service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/apps": {
      "get": {
        "operationId": "get_apps",
        "summary": "Look up app details by IDs",
        "description": "Get multiple app details by IDs",
        "deprecated": false,
        "tags": [
          "Apps"
        ],
        "parameters": [
          {
            "name": "ids",
            "in": "query",
            "required": true,
            "description": "Array of App IDs (UUIDs). Use bracket notation for array encoding. Example: `/data_exports/v1/apps?ids[]=a1b2c3d4-5678-9abc-def0-111111111111&ids[]=a1b2c3d4-5678-9abc-def0-222222222222`",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get multiple app details by IDs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/App"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Forbidden - Missing or invalid authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Unauthorized - Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/ad-networks": {
      "get": {
        "operationId": "get_ad_networks",
        "summary": "Look up ad network details by IDs",
        "description": "Get multiple ad network details by IDs",
        "deprecated": false,
        "tags": [
          "Ad Networks"
        ],
        "parameters": [
          {
            "name": "ids",
            "in": "query",
            "required": true,
            "description": "Array of Ad Network IDs (integers). Use bracket notation for array encoding. Example: `/data_exports/v1/ad-networks?ids[]=123&ids[]=456`",
            "schema": {
              "type": "array",
              "items": {
                "type": "integer"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get multiple ad network details by IDs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AdNetwork"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Forbidden - Missing or invalid authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Unauthorized - Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/event_types": {
      "get": {
        "operationId": "get_event_types",
        "summary": "List available event type groups",
        "description": "Get available event types for filtering exports",
        "deprecated": true,
        "tags": [
          "Event type groups"
        ],
        "responses": {
          "200": {
            "description": "Get available event types for filtering exports",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EventTypeGroup"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Forbidden - Missing or invalid authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Unauthorized - Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/event_type_groups": {
      "get": {
        "operationId": "get_event_type_groups",
        "summary": "List available event type groups",
        "description": "Get available event type groups for filtering exports",
        "deprecated": false,
        "tags": [
          "Event type groups"
        ],
        "responses": {
          "200": {
            "description": "Get available event type groups for filtering exports",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EventTypeGroup"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Forbidden - Missing or invalid authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Unauthorized - Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DataExport": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Export ID"
          },
          "status": {
            "type": "string",
            "description": "Current state (pending, processing, completed, failed)"
          },
          "limited_rows": {
            "type": "boolean",
            "description": "Whether row count was limited"
          },
          "app_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "App IDs included in this export"
          },
          "ad_network_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Ad Network IDs included in this export"
          },
          "event_type_groups": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Event type groups included in this export"
          },
          "event_types": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "DEPRECATED — use event_type_groups"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Creation timestamp (ISO8601)"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "Last update timestamp (ISO8601)"
          },
          "start_date": {
            "type": "string",
            "format": "date",
            "description": "Start date (ISO8601)"
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "End date (ISO8601)"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Exact expiry timestamp (ISO8601), 24 hours after creation. Downloads return 410 Gone after this; files are deleted shortly afterwards."
          },
          "expiration_date": {
            "type": "string",
            "format": "date",
            "description": "DEPRECATED — use expires_at. Date portion of expires_at: the export expires during this UTC day, not at its end."
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FileInfo"
            },
            "description": "Files available for download"
          }
        },
        "required": [
          "id",
          "status",
          "limited_rows",
          "app_ids",
          "ad_network_ids",
          "event_type_groups",
          "event_types",
          "created_at",
          "updated_at",
          "start_date",
          "end_date",
          "expires_at",
          "expiration_date",
          "files"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Error message (same as title, for backward compatibility)"
          },
          "type": {
            "type": "string",
            "description": "URI identifying the problem type"
          },
          "title": {
            "type": "string",
            "description": "Short, human-readable summary"
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code"
          },
          "detail": {
            "type": "string",
            "description": "Human-readable explanation specific to this occurrence"
          }
        },
        "required": [
          "error",
          "type",
          "title",
          "status"
        ]
      },
      "post_exports_Request": {
        "type": "object",
        "properties": {
          "start_date": {
            "type": "string",
            "format": "date",
            "description": "Start date for the export (YYYY-MM-DD format)"
          },
          "end_date": {
            "type": "string",
            "format": "date",
            "description": "End date for the export (YYYY-MM-DD format)"
          },
          "event_type_groups": {
            "type": "array",
            "description": "List of event type groups to include in the export",
            "items": {
              "type": "string",
              "enum": [
                "app_open",
                "custom_events",
                "in_app_purchases",
                "subscription",
                "ilrd",
                "ad_engagement",
                "fraud",
                "skan_cv",
                "installs",
                "in_app_events"
              ]
            }
          },
          "event_types": {
            "type": "array",
            "description": "DEPRECATED — use event_type_groups. List of event type groups to include in the export",
            "items": {
              "type": "string",
              "enum": [
                "app_open",
                "custom_events",
                "in_app_purchases",
                "subscription",
                "ilrd",
                "ad_engagement",
                "fraud",
                "skan_cv",
                "installs",
                "in_app_events"
              ]
            }
          },
          "limited_rows": {
            "type": "boolean",
            "description": "Whether to limit the number of rows in the export",
            "default": false
          },
          "app_id": {
            "type": "string",
            "description": "App ID to export data for"
          },
          "ad_network_ids": {
            "type": "array",
            "description": "Ad Network IDs to filter the export (optional)",
            "items": {
              "type": "integer"
            },
            "default": []
          }
        },
        "required": [
          "start_date",
          "end_date",
          "app_id"
        ]
      },
      "App": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "App ID"
          },
          "name": {
            "type": "string",
            "description": "App name"
          },
          "icon_url": {
            "type": "string",
            "description": "App icon URL"
          }
        },
        "required": [
          "id",
          "name",
          "icon_url"
        ]
      },
      "AdNetwork": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Ad Network ID"
          },
          "name": {
            "type": "string",
            "description": "Ad Network name"
          },
          "icon_url": {
            "type": "string",
            "description": "Ad Network icon URL"
          }
        },
        "required": [
          "id",
          "name",
          "icon_url"
        ]
      },
      "EventTypeGroup": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Event type group identifier (use this value when filtering exports)"
          },
          "name": {
            "type": "string",
            "description": "Human-readable event type group name"
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "FileInfo": {
        "type": "object",
        "description": "Files available for download",
        "properties": {
          "s3_uri": {
            "type": "string"
          },
          "file_size": {
            "type": "integer"
          },
          "download_url": {
            "type": "string",
            "description": "API path that redirects (303) to a presigned S3 download URL"
          }
        },
        "required": [
          "s3_uri",
          "file_size",
          "download_url"
        ]
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Generate an access token on the [Access Tokens](https://dashboard.tenjin.com/dashboard/access_tokens) page of the Tenjin dashboard and send it as `Authorization: Bearer <access token>`. [API access tokens](https://tenjin.com/docs/api-access-tokens/) explains them."
      }
    }
  },
  "security": [
    {
      "Bearer": []
    }
  ]
}
