{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/paubox/main/json-schema/paubox-subscription-change-response-schema.json",
  "title": "SubscriptionChangeResponse",
  "description": "The affected subscribers in JSON:API form. Returned with HTTP 200; on failure the body carries `errors` instead of `data`.",
  "x-generated": "2026-10-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/paubox-subscriptions-api-openapi.yml#/components/schemas/SubscriptionChangeResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DetailedSubscriber"
      }
    },
    "errors": {
      "type": "string",
      "description": "Error message, present only when the operation failed"
    }
  },
  "$defs": {
    "DetailedSubscriber": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier for the subscriber"
        },
        "type": {
          "type": "string",
          "description": "Resource type"
        },
        "attributes": {
          "$ref": "#/$defs/DetailedSubscriber_attributes"
        }
      }
    },
    "DetailedSubscriber_attributes": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "description": "Subscriber's email address",
          "format": "email"
        },
        "first_name": {
          "type": "string",
          "description": "Subscriber's first name"
        },
        "last_name": {
          "type": "string",
          "description": "Subscriber's last name"
        },
        "unsubscribed": {
          "type": "boolean",
          "description": "Whether the subscriber is unsubscribed"
        },
        "created_at": {
          "type": "string",
          "description": "Timestamp when subscriber was created",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "description": "Timestamp when subscriber was last updated",
          "format": "date-time"
        },
        "custom_fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DetailedSubscriber_attributes_custom_fields"
          }
        },
        "subscription_lists": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DetailedSubscriber_attributes_subscription_lists"
          }
        },
        "statistics": {
          "$ref": "#/$defs/DetailedSubscriber_attributes_statistics"
        }
      }
    },
    "DetailedSubscriber_attributes_custom_fields": {
      "type": "object",
      "properties": {
        "subscriber_custom_field_type_id": {
          "type": "string",
          "description": "ID of the custom field type"
        },
        "custom_field_name": {
          "type": "string",
          "description": "Name of the custom field"
        },
        "custom_field_value": {
          "type": "string",
          "description": "Value of the custom field"
        }
      }
    },
    "DetailedSubscriber_attributes_statistics": {
      "type": "object",
      "properties": {
        "deliveries": {
          "type": "integer",
          "description": "Number of deliveries"
        },
        "delivered": {
          "type": "integer",
          "description": "Number of delivered emails"
        },
        "opened": {
          "type": "integer",
          "description": "Number of opened emails"
        },
        "clicked": {
          "type": "integer",
          "description": "Number of clicked emails"
        },
        "soft_bounced": {
          "type": "integer",
          "description": "Number of soft bounces"
        },
        "hard_bounced": {
          "type": "integer",
          "description": "Number of hard bounces"
        },
        "unsubscribed": {
          "type": "integer",
          "description": "Number of unsubscribes"
        },
        "global_unsubscribed": {
          "type": "integer",
          "description": "Number of global unsubscribes"
        }
      }
    },
    "DetailedSubscriber_attributes_subscription_lists": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Subscription list ID"
        },
        "name": {
          "type": "string",
          "description": "Subscription list name"
        },
        "unsubscribed": {
          "type": "boolean",
          "description": "Whether subscriber is unsubscribed from this list"
        }
      }
    }
  }
}