{
  "openapi": "3.0.3",
  "info": {
    "title": "Grade update schedules",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://infra-sandbox.usegrade.com/api",
      "description": "Sandbox"
    },
    {
      "url": "https://infra.usegrade.com/api/email",
      "description": "Production"
    }
  ],
  "security": [
    {
      "applicationId": [],
      "apiKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "applicationId": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Application-Id"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key"
      }
    },
    "schemas": {
      "UpdateScheduleBody": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "schema",
              "name",
              "budget",
              "when",
              "steps"
            ],
            "properties": {
              "schema": {
                "type": "string",
                "enum": [
                  "check-rule/v1"
                ]
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "budget": {
                "type": "object",
                "required": [
                  "monthly_usd",
                  "when_reached"
                ],
                "properties": {
                  "monthly_usd": {
                    "type": "number",
                    "minimum": 0,
                    "not": {
                      "enum": [
                        0
                      ]
                    },
                    "maximum": 10000
                  },
                  "when_reached": {
                    "type": "string",
                    "enum": [
                      "daily_check_only"
                    ]
                  }
                },
                "additionalProperties": false
              },
              "when": {
                "type": "object",
                "required": [
                  "event",
                  "platforms",
                  "find_within_minutes"
                ],
                "properties": {
                  "event": {
                    "type": "string",
                    "enum": [
                      "post_uploaded"
                    ]
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "instagram",
                        "tiktok",
                        "youtube",
                        "facebook",
                        "twitter"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 5,
                    "uniqueItems": true
                  },
                  "find_within_minutes": {
                    "type": "integer",
                    "enum": [
                      30,
                      60,
                      90,
                      120,
                      150,
                      180,
                      210,
                      240,
                      270,
                      300,
                      330,
                      360,
                      1440
                    ]
                  }
                },
                "additionalProperties": false
              },
              "steps": {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "type",
                        "to",
                        "message",
                        "once_per_post"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "alert"
                          ]
                        },
                        "to": {
                          "type": "string",
                          "enum": [
                            "slack",
                            "discord",
                            "webhook"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "enum": [
                            "post_uploaded",
                            "post_taking_off",
                            "latest_numbers"
                          ]
                        },
                        "once_per_post": {
                          "type": "boolean"
                        }
                      },
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "required": [
                        "type"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "check_now"
                          ]
                        }
                      },
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "required": [
                        "type",
                        "every_minutes",
                        "for_hours",
                        "on_each_check"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "check"
                          ]
                        },
                        "every_minutes": {
                          "type": "integer",
                          "minimum": 5,
                          "maximum": 360,
                          "multipleOf": 5
                        },
                        "for_hours": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 72
                        },
                        "on_each_check": {
                          "type": "array",
                          "items": {
                            "oneOf": [
                              {
                                "type": "object",
                                "required": [
                                  "type",
                                  "to",
                                  "message",
                                  "once_per_post"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "alert"
                                    ]
                                  },
                                  "to": {
                                    "type": "string",
                                    "enum": [
                                      "slack",
                                      "discord",
                                      "webhook"
                                    ]
                                  },
                                  "message": {
                                    "type": "string",
                                    "enum": [
                                      "post_uploaded",
                                      "post_taking_off",
                                      "latest_numbers"
                                    ]
                                  },
                                  "once_per_post": {
                                    "type": "boolean"
                                  }
                                },
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "required": [
                                  "type",
                                  "metric",
                                  "reaches",
                                  "compared_with",
                                  "then"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "if"
                                    ]
                                  },
                                  "metric": {
                                    "type": "string",
                                    "enum": [
                                      "views",
                                      "likes",
                                      "comments",
                                      "shares"
                                    ]
                                  },
                                  "reaches": {
                                    "type": "number",
                                    "minimum": 0,
                                    "not": {
                                      "enum": [
                                        0
                                      ]
                                    },
                                    "maximum": 1000000000
                                  },
                                  "compared_with": {
                                    "type": "string",
                                    "enum": [
                                      "fixed_number",
                                      "creator_usual_first_day"
                                    ],
                                    "description": "Use fixed_number when saving or activating. A historical rule can reference the creator’s usual first day."
                                  },
                                  "then": {
                                    "type": "array",
                                    "items": {
                                      "oneOf": [
                                        {
                                          "type": "object",
                                          "required": [
                                            "type",
                                            "to",
                                            "message",
                                            "once_per_post"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "alert"
                                              ]
                                            },
                                            "to": {
                                              "type": "string",
                                              "enum": [
                                                "slack",
                                                "discord",
                                                "webhook"
                                              ]
                                            },
                                            "message": {
                                              "type": "string",
                                              "enum": [
                                                "post_uploaded",
                                                "post_taking_off",
                                                "latest_numbers"
                                              ]
                                            },
                                            "once_per_post": {
                                              "type": "boolean"
                                            }
                                          },
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "required": [
                                            "type"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "check_now"
                                              ]
                                            }
                                          },
                                          "additionalProperties": false
                                        }
                                      ]
                                    },
                                    "minItems": 1,
                                    "maxItems": 6
                                  }
                                },
                                "additionalProperties": false
                              }
                            ]
                          },
                          "maxItems": 6
                        }
                      },
                      "additionalProperties": false
                    }
                  ]
                },
                "minItems": 1,
                "maxItems": 12
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "schema",
              "name",
              "budget",
              "when"
            ],
            "properties": {
              "schema": {
                "type": "string",
                "enum": [
                  "check-rule/v1"
                ]
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "budget": {
                "type": "object",
                "required": [
                  "monthly_usd",
                  "when_reached"
                ],
                "properties": {
                  "monthly_usd": {
                    "type": "number",
                    "minimum": 0,
                    "not": {
                      "enum": [
                        0
                      ]
                    },
                    "maximum": 10000
                  },
                  "when_reached": {
                    "type": "string",
                    "enum": [
                      "daily_check_only"
                    ]
                  }
                },
                "additionalProperties": false
              },
              "when": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "event",
                      "timezone",
                      "platforms",
                      "times"
                    ],
                    "properties": {
                      "event": {
                        "type": "string",
                        "enum": [
                          "schedule"
                        ]
                      },
                      "timezone": {
                        "type": "string"
                      },
                      "platforms": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "instagram",
                            "tiktok",
                            "youtube",
                            "facebook",
                            "twitter"
                          ]
                        },
                        "minItems": 1,
                        "maxItems": 5,
                        "uniqueItems": true
                      },
                      "uploaded_within_days": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 365
                      },
                      "times": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^(?:[01]\\d|2[0-3]):[0-5][05]$"
                        },
                        "minItems": 1,
                        "maxItems": 24,
                        "uniqueItems": true
                      }
                    },
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "required": [
                      "event",
                      "timezone",
                      "platforms",
                      "every_hours"
                    ],
                    "properties": {
                      "event": {
                        "type": "string",
                        "enum": [
                          "schedule"
                        ]
                      },
                      "timezone": {
                        "type": "string"
                      },
                      "platforms": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "instagram",
                            "tiktok",
                            "youtube",
                            "facebook",
                            "twitter"
                          ]
                        },
                        "minItems": 1,
                        "maxItems": 5,
                        "uniqueItems": true
                      },
                      "uploaded_within_days": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 365
                      },
                      "every_hours": {
                        "type": "integer",
                        "enum": [
                          1,
                          2,
                          3,
                          4,
                          6,
                          8,
                          12
                        ]
                      }
                    },
                    "additionalProperties": false
                  }
                ]
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "UpdateScheduleRow": {
        "type": "object",
        "required": [
          "id",
          "name",
          "kind",
          "campaign",
          "status",
          "version",
          "body",
          "turnedOnAt",
          "updatedAt",
          "thisMonth",
          "pausedToday"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "post_uploaded",
              "schedule"
            ]
          },
          "campaign": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "id",
                  "name"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "ON",
              "OFF"
            ]
          },
          "version": {
            "type": "integer",
            "minimum": 0
          },
          "body": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UpdateScheduleBody"
              },
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ]
          },
          "turnedOnAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "thisMonth": {
            "type": "object",
            "required": [
              "postUpdates",
              "accountUpdates",
              "costUsd"
            ],
            "properties": {
              "postUpdates": {
                "type": "integer",
                "minimum": 0
              },
              "accountUpdates": {
                "type": "integer",
                "minimum": 0
              },
              "costUsd": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false
          },
          "pausedToday": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "reason",
                  "count",
                  "lastAt"
                ],
                "properties": {
                  "reason": {
                    "type": "string",
                    "enum": [
                      "RULE_LIMIT",
                      "DAILY_CAP",
                      "BALANCE"
                    ]
                  },
                  "count": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "lastAt": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "UpdateScheduleDailyLimit": {
        "type": "object",
        "required": [
          "limit",
          "postUpdatesToday",
          "min",
          "max"
        ],
        "properties": {
          "limit": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000
          },
          "postUpdatesToday": {
            "type": "integer",
            "minimum": 0
          },
          "min": {
            "type": "integer",
            "minimum": 0
          },
          "max": {
            "type": "integer",
            "minimum": 0
          }
        },
        "additionalProperties": false
      },
      "UpdateScheduleOverview": {
        "type": "object",
        "required": [
          "asOf",
          "running",
          "pricePerUpdateUsd",
          "dailyLimit",
          "schedules",
          "billing"
        ],
        "properties": {
          "asOf": {
            "type": "string",
            "format": "date-time"
          },
          "running": {
            "type": "boolean"
          },
          "pricePerUpdateUsd": {
            "type": "number",
            "minimum": 0
          },
          "dailyLimit": {
            "$ref": "#/components/schemas/UpdateScheduleDailyLimit"
          },
          "schedules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UpdateScheduleRow"
            }
          },
          "billing": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "chargedThisMonthUsd",
                  "notChargedYetUsd",
                  "lastChargedDay",
                  "pausedForBalance"
                ],
                "properties": {
                  "chargedThisMonthUsd": {
                    "type": "number",
                    "minimum": 0
                  },
                  "notChargedYetUsd": {
                    "type": "number",
                    "minimum": 0
                  },
                  "lastChargedDay": {
                    "type": "string",
                    "format": "date",
                    "nullable": true
                  },
                  "pausedForBalance": {
                    "oneOf": [
                      {
                        "type": "object",
                        "required": [
                          "since"
                        ],
                        "properties": {
                          "since": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "nullable": true,
                        "enum": [
                          null
                        ]
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "UpdateScheduleEstimate": {
        "type": "object",
        "required": [
          "asOf",
          "issues",
          "postsInScope",
          "newPostsPerMonth",
          "accountsInScope",
          "perDay",
          "perMonth",
          "parts",
          "notes"
        ],
        "properties": {
          "asOf": {
            "type": "string",
            "format": "date-time"
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "path",
                "message"
              ],
              "properties": {
                "path": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          },
          "postsInScope": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "newPostsPerMonth": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "accountsInScope": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "perDay": {
            "type": "object",
            "required": [
              "postUpdates",
              "accountUpdates",
              "overDailyLimit"
            ],
            "properties": {
              "postUpdates": {
                "type": "integer",
                "minimum": 0
              },
              "accountUpdates": {
                "type": "integer",
                "minimum": 0
              },
              "overDailyLimit": {
                "type": "integer",
                "minimum": 0
              }
            },
            "additionalProperties": false
          },
          "perMonth": {
            "type": "object",
            "required": [
              "postUpdates",
              "accountUpdates",
              "alerts",
              "costUsd",
              "costWithoutLimitsUsd",
              "monthlyLimitReachedOnDay"
            ],
            "properties": {
              "postUpdates": {
                "type": "integer",
                "minimum": 0
              },
              "accountUpdates": {
                "type": "integer",
                "minimum": 0
              },
              "alerts": {
                "type": "integer",
                "minimum": 0,
                "nullable": true
              },
              "costUsd": {
                "type": "number",
                "minimum": 0
              },
              "costWithoutLimitsUsd": {
                "type": "number",
                "minimum": 0
              },
              "monthlyLimitReachedOnDay": {
                "type": "integer",
                "minimum": 1,
                "nullable": true,
                "maximum": 30
              }
            },
            "additionalProperties": false
          },
          "parts": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "path",
                "label",
                "updatesPerMonth",
                "costUsd"
              ],
              "properties": {
                "path": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "updatesPerMonth": {
                  "type": "integer",
                  "minimum": 0
                },
                "costUsd": {
                  "type": "number",
                  "minimum": 0
                }
              },
              "additionalProperties": false
            }
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      },
      "UpdateScheduleQueuedUpdate": {
        "type": "object",
        "required": [
          "updateId",
          "scheduleId",
          "version",
          "mediaType",
          "mediaId",
          "queuedAt",
          "currency",
          "unitPriceUsd",
          "status"
        ],
        "properties": {
          "updateId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "scheduleId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "mediaType": {
            "type": "string",
            "enum": [
              "CCM",
              "ATM"
            ]
          },
          "mediaId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "queuedAt": {
            "type": "string",
            "format": "date-time"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "unitPriceUsd": {
            "type": "number",
            "minimum": 0
          },
          "status": {
            "type": "string",
            "enum": [
              "queued"
            ]
          }
        },
        "additionalProperties": false
      },
      "UpdateScheduleReceipt": {
        "type": "object",
        "required": [
          "updateId",
          "scheduleId",
          "version",
          "mediaType",
          "mediaId",
          "queuedAt",
          "currency",
          "unitPriceUsd",
          "status",
          "billing"
        ],
        "properties": {
          "updateId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "scheduleId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "mediaType": {
            "type": "string",
            "enum": [
              "CCM",
              "ATM"
            ]
          },
          "mediaId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "queuedAt": {
            "type": "string",
            "format": "date-time"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "unitPriceUsd": {
            "type": "number",
            "minimum": 0
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "dispatching",
              "awaiting_settlement",
              "provider_accepted",
              "settled_without_run"
            ]
          },
          "billing": {
            "type": "object",
            "required": [
              "status",
              "billableUsd",
              "chargeId",
              "settledAt"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "reserved",
                  "billable",
                  "settled",
                  "settled_without_charge"
                ]
              },
              "billableUsd": {
                "type": "number",
                "minimum": 0
              },
              "chargeId": {
                "type": "string",
                "nullable": true
              },
              "settledAt": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "UpdateScheduleError": {
        "type": "object",
        "required": [
          "success",
          "message"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "field": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "path",
                "message"
              ],
              "properties": {
                "path": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    }
  },
  "paths": {
    "/sdk/v1/update-schedules": {
      "get": {
        "operationId": "getUpdateScheduleOverview",
        "summary": "Read update schedules and organization billing",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Read update schedules and organization billing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/UpdateScheduleOverview"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, field or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid SDK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "403": {
            "description": "Access or required scope unavailable, or Update schedule not opened to the organization (UPDATE_SCHEDULE_NOT_RELEASED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "404": {
            "description": "Resource is outside scope or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          }
        },
        "x-required-scopes": [
          "scraping:read"
        ],
        "description": "Requires scraping:read."
      },
      "post": {
        "operationId": "createUpdateSchedule",
        "summary": "Save a new schedule, initially off",
        "parameters": [
          {
            "name": "X-Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[!-~]+$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Save a new schedule, initially off",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/UpdateScheduleRow"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, field or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid SDK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "403": {
            "description": "Access or required scope unavailable, or Update schedule not opened to the organization (UPDATE_SCHEDULE_NOT_RELEASED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "404": {
            "description": "Resource is outside scope or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "409": {
            "description": "State, limit or idempotency conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          }
        },
        "x-required-scopes": [
          "scraping:write"
        ],
        "description": "Requires scraping:write. Persist one idempotency key per intent. Retry the same operation, resource and body to replay the committed response.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "campaignId",
                  "body"
                ],
                "properties": {
                  "campaignId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64,
                    "nullable": true
                  },
                  "body": {
                    "$ref": "#/components/schemas/UpdateScheduleBody"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/sdk/v1/update-schedules/{id}": {
      "get": {
        "operationId": "getUpdateSchedule",
        "summary": "Read a schedule and its active version",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Read a schedule and its active version",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/UpdateScheduleRow"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, field or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid SDK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "403": {
            "description": "Access or required scope unavailable, or Update schedule not opened to the organization (UPDATE_SCHEDULE_NOT_RELEASED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "404": {
            "description": "Resource is outside scope or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          }
        },
        "x-required-scopes": [
          "scraping:read"
        ],
        "description": "Requires scraping:read."
      }
    },
    "/sdk/v1/update-schedules/estimate": {
      "post": {
        "operationId": "estimateUpdateSchedule",
        "summary": "Estimate a saved schedule or a draft",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Estimate a saved schedule or a draft",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/UpdateScheduleEstimate"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, field or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid SDK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "403": {
            "description": "Access or required scope unavailable, or Update schedule not opened to the organization (UPDATE_SCHEDULE_NOT_RELEASED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "404": {
            "description": "Resource is outside scope or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          }
        },
        "x-required-scopes": [
          "scraping:read"
        ],
        "description": "Requires scraping:read. Prices 30 days without saving, queueing or spending. A dailyLimit override applies only to this estimate.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "checkRuleId"
                    ],
                    "properties": {
                      "checkRuleId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "dailyLimit": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000000
                      }
                    },
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "required": [
                      "campaignId",
                      "body"
                    ],
                    "properties": {
                      "campaignId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "nullable": true
                      },
                      "body": {
                        "$ref": "#/components/schemas/UpdateScheduleBody"
                      },
                      "dailyLimit": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000000
                      }
                    },
                    "additionalProperties": false
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/sdk/v1/update-schedules/{id}/versions": {
      "post": {
        "operationId": "saveUpdateScheduleVersion",
        "summary": "Save the next schedule version",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "X-Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[!-~]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Save the next schedule version",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/UpdateScheduleRow"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, field or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid SDK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "403": {
            "description": "Access or required scope unavailable, or Update schedule not opened to the organization (UPDATE_SCHEDULE_NOT_RELEASED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "404": {
            "description": "Resource is outside scope or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "409": {
            "description": "State, limit or idempotency conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          }
        },
        "x-required-scopes": [
          "scraping:write"
        ],
        "description": "Requires scraping:write. Editing an active schedule changes its live version. Persist one idempotency key per intent. Retry the same operation, resource and body to replay the committed response.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "body",
                  "expectedVersion",
                  "expectedStatus",
                  "expectedDailyLimit"
                ],
                "properties": {
                  "body": {
                    "$ref": "#/components/schemas/UpdateScheduleBody"
                  },
                  "expectedVersion": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2147483647
                  },
                  "expectedStatus": {
                    "type": "string",
                    "enum": [
                      "ON",
                      "OFF"
                    ]
                  },
                  "expectedDailyLimit": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/sdk/v1/update-schedules/{id}/status": {
      "post": {
        "operationId": "setUpdateScheduleStatus",
        "summary": "Turn a reviewed schedule on or off",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "X-Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[!-~]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Turn a reviewed schedule on or off",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/UpdateScheduleRow"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, field or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid SDK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "403": {
            "description": "Access or required scope unavailable, or Update schedule not opened to the organization (UPDATE_SCHEDULE_NOT_RELEASED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "404": {
            "description": "Resource is outside scope or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "409": {
            "description": "State, limit or idempotency conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          }
        },
        "x-required-scopes": [
          "scraping:write"
        ],
        "description": "Requires scraping:write. Persist one idempotency key per intent. Retry the same operation, resource and body to replay the committed response.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "status",
                      "expectedVersion",
                      "expectedStatus",
                      "expectedDailyLimit"
                    ],
                    "properties": {
                      "status": {
                        "type": "string",
                        "enum": [
                          "ON"
                        ]
                      },
                      "expectedVersion": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 2147483647
                      },
                      "expectedStatus": {
                        "type": "string",
                        "enum": [
                          "ON",
                          "OFF"
                        ]
                      },
                      "expectedDailyLimit": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000000
                      }
                    },
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "required": [
                      "status",
                      "expectedVersion",
                      "expectedStatus"
                    ],
                    "properties": {
                      "status": {
                        "type": "string",
                        "enum": [
                          "OFF"
                        ]
                      },
                      "expectedVersion": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 2147483647
                      },
                      "expectedStatus": {
                        "type": "string",
                        "enum": [
                          "ON",
                          "OFF"
                        ]
                      },
                      "expectedDailyLimit": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000000
                      }
                    },
                    "additionalProperties": false
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/sdk/v1/update-schedules/daily-limit": {
      "put": {
        "operationId": "setUpdateScheduleDailyLimit",
        "summary": "Change the shared organization daily limit",
        "parameters": [
          {
            "name": "X-Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[!-~]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Change the shared organization daily limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/UpdateScheduleDailyLimit"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, field or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid SDK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "403": {
            "description": "Access or required scope unavailable, or Update schedule not opened to the organization (UPDATE_SCHEDULE_NOT_RELEASED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "404": {
            "description": "Resource is outside scope or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "409": {
            "description": "State, limit or idempotency conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          }
        },
        "x-required-scopes": [
          "scraping:write"
        ],
        "description": "Requires scraping:write. Persist one idempotency key per intent. Retry the same operation, resource and body to replay the committed response.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "dailyLimit",
                  "expectedDailyLimit"
                ],
                "properties": {
                  "dailyLimit": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000
                  },
                  "expectedDailyLimit": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/sdk/v1/update-schedules/{id}/updates": {
      "post": {
        "operationId": "requestScheduledPostUpdate",
        "summary": "Request one paid update for an eligible post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "X-Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[!-~]+$"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Request one paid update for an eligible post",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/UpdateScheduleQueuedUpdate"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, field or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid SDK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "402": {
            "description": "Wallet cannot cover this update",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "403": {
            "description": "Access or required scope unavailable, or Update schedule not opened to the organization (UPDATE_SCHEDULE_NOT_RELEASED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "404": {
            "description": "Resource is outside scope or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "409": {
            "description": "State, limit or idempotency conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "429": {
            "description": "Key allowance or runtime capacity reached; observe Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds before retry",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "503": {
            "description": "Paid updates or platform unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          }
        },
        "x-required-scopes": [
          "scraping:write"
        ],
        "description": "Requires scraping:write. Admission reserves one update. Provider acceptance makes it billable. The default per-key allowance is 100 accepted requests per UTC day. Rotation preserves its allowance and usage. Persist one idempotency key per intent. Retry the same operation, resource and body to replay the committed response.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "mediaType",
                  "mediaId",
                  "expectedVersion"
                ],
                "properties": {
                  "mediaType": {
                    "type": "string",
                    "enum": [
                      "CCM",
                      "ATM"
                    ]
                  },
                  "mediaId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  "expectedVersion": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2147483647
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/sdk/v1/update-schedules/{id}/updates/{updateId}": {
      "get": {
        "operationId": "getScheduledPostUpdate",
        "summary": "Read the dispatch and billing receipt",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "updateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Read the dispatch and billing receipt",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/UpdateScheduleReceipt"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, field or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid SDK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "403": {
            "description": "Access or required scope unavailable, or Update schedule not opened to the organization (UPDATE_SCHEDULE_NOT_RELEASED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          },
          "404": {
            "description": "Resource is outside scope or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateScheduleError"
                }
              }
            }
          }
        },
        "x-required-scopes": [
          "scraping:read"
        ],
        "description": "Requires scraping:read. Visible to the same application and organization, including after API key rotation."
      }
    }
  }
}
