OpenSocialDocumentação

batches_register

Registrar um lote validado com identidades persistentes para cada destino.

REST · POST /api/v1/operations/batches_register · MCP · batches_register

Permissão necessária · publish. Envie Idempotency-Key no REST ou requestKey no MCP. Substitua IDs e datas do exemplo antes de executar.

Exemplo de entrada

{
  "manifest": {
    "version": 1,
    "batchId": "99ae140f-7526-4e8a-89c2-c6d0d103010d",
    "projectId": "PROJECT_ID",
    "timezone": "America/Sao_Paulo",
    "items": [
      {
        "itemId": "video-01",
        "source": {
          "mediaId": "MEDIA_ID"
        },
        "targets": [
          {
            "account": {
              "accountId": "ACCOUNT_ID"
            },
            "at": "2030-07-01T18:00:00-03:00"
          }
        ]
      }
    ]
  }
}

O REST retorna a saída abaixo diretamente. No MCP leia structuredContent.result. Consulte o contrato atual em /api/v1/openapi.json.

Em 401 confira a validade da credencial. Em 403 confira papel, escopos e contas. Em 409 releia o registro antes de tentar novamente.

JSON Schema · Entrada

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "manifest": {
      "type": "object",
      "properties": {
        "version": {
          "type": "number",
          "const": 1
        },
        "batchId": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "projectId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "timezone": {
          "type": "string",
          "maxLength": 80
        },
        "items": {
          "minItems": 1,
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "itemId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              "caption": {
                "default": "",
                "type": "string",
                "maxLength": 12000
              },
              "hashtags": {
                "default": [],
                "maxItems": 100,
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 100
                }
              },
              "targets": {
                "minItems": 1,
                "maxItems": 20,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "account": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "accountId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 128
                            }
                          },
                          "required": [
                            "accountId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "platform": {
                              "type": "string",
                              "enum": [
                                "youtube",
                                "instagram",
                                "tiktok"
                              ]
                            },
                            "handle": {
                              "type": "string",
                              "maxLength": 128,
                              "pattern": "^@[^\\s@/?#]+$"
                            }
                          },
                          "required": [
                            "platform",
                            "handle"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "at": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                    },
                    "options": {
                      "default": {},
                      "type": "object",
                      "properties": {
                        "caption": {
                          "type": "string",
                          "maxLength": 12000
                        },
                        "hashtags": {
                          "maxItems": 100,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "maxLength": 100
                          }
                        },
                        "title": {
                          "type": "string",
                          "maxLength": 200
                        },
                        "visibility": {
                          "type": "string",
                          "enum": [
                            "public",
                            "unlisted",
                            "private"
                          ]
                        },
                        "coverMs": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "madeForKids": {
                          "type": "boolean"
                        },
                        "tiktok": {
                          "type": "object",
                          "properties": {
                            "privacy": {
                              "type": "string",
                              "enum": [
                                "PUBLIC_TO_EVERYONE",
                                "FOLLOWER_OF_CREATOR",
                                "MUTUAL_FOLLOW_FRIENDS",
                                "SELF_ONLY"
                              ]
                            },
                            "comment": {
                              "type": "boolean"
                            },
                            "duet": {
                              "type": "boolean"
                            },
                            "stitch": {
                              "type": "boolean"
                            },
                            "commercial": {
                              "type": "boolean"
                            },
                            "ownBrand": {
                              "type": "boolean"
                            },
                            "brandedContent": {
                              "type": "boolean"
                            },
                            "aiGenerated": {
                              "type": "boolean"
                            }
                          },
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "account",
                    "at"
                  ],
                  "additionalProperties": false
                }
              },
              "source": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "mediaId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 128
                      }
                    },
                    "required": [
                      "mediaId"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "upload": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 140,
                            "pattern": "^[^/\\\\\\u0000-\\u001f]+$"
                          },
                          "sha256": {
                            "type": "string",
                            "pattern": "^[0-9a-f]{64}$"
                          },
                          "metadata": {
                            "type": "object",
                            "properties": {
                              "mime": {
                                "type": "string",
                                "enum": [
                                  "video/mp4",
                                  "video/quicktime"
                                ]
                              },
                              "width": {
                                "type": "integer",
                                "exclusiveMinimum": 0,
                                "maximum": 9007199254740991
                              },
                              "height": {
                                "type": "integer",
                                "exclusiveMinimum": 0,
                                "maximum": 9007199254740991
                              },
                              "duration": {
                                "type": "number",
                                "exclusiveMinimum": 0
                              },
                              "size": {
                                "type": "integer",
                                "exclusiveMinimum": 0,
                                "maximum": 9007199254740991
                              },
                              "codec": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 40
                              },
                              "audioCodec": {
                                "default": null,
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 40
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            },
                            "required": [
                              "mime",
                              "width",
                              "height",
                              "duration",
                              "size",
                              "codec"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "name",
                          "sha256",
                          "metadata"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "upload"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            },
            "required": [
              "itemId",
              "targets",
              "source"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "version",
        "batchId",
        "projectId",
        "timezone",
        "items"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "manifest"
  ],
  "additionalProperties": false
}

JSON Schema · Saída

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "batchId": {
      "type": "string"
    },
    "projectId": {
      "type": "string"
    },
    "existing": {
      "type": "boolean"
    },
    "canApply": {
      "type": "boolean"
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "diagnosis": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "firstRequestAt": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "lastCheckedAt": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "reviewUrl": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "stage": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "cause": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "attemptId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "originalDueAt": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "effectiveDueAt": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "delaySeconds": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "nextAt": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "canRetry": {
                    "type": "boolean"
                  },
                  "canRevise": {
                    "type": "boolean"
                  },
                  "canReconcile": {
                    "type": "boolean"
                  },
                  "canResume": {
                    "type": "boolean"
                  },
                  "needsReview": {
                    "type": "boolean"
                  },
                  "action": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "firstRequestAt",
                  "lastCheckedAt",
                  "reviewUrl",
                  "stage",
                  "cause",
                  "attemptId",
                  "originalDueAt",
                  "effectiveDueAt",
                  "delaySeconds",
                  "nextAt",
                  "canRetry",
                  "canRevise",
                  "canReconcile",
                  "canResume",
                  "needsReview",
                  "action"
                ],
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          },
          "itemId": {
            "type": "string"
          },
          "accountId": {
            "type": [
              "string",
              "null"
            ]
          },
          "accountName": {
            "type": [
              "string",
              "null"
            ]
          },
          "platform": {
            "type": [
              "string",
              "null"
            ]
          },
          "handle": {
            "type": [
              "string",
              "null"
            ]
          },
          "mediaId": {
            "type": [
              "string",
              "null"
            ]
          },
          "mediaName": {
            "type": [
              "string",
              "null"
            ]
          },
          "mediaStatus": {
            "type": [
              "string",
              "null"
            ]
          },
          "publicationId": {
            "type": [
              "string",
              "null"
            ]
          },
          "remoteId": {
            "type": [
              "string",
              "null"
            ]
          },
          "remoteUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "at": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "confirmation": {
            "type": [
              "string",
              "null"
            ]
          },
          "problems": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "action": {
                  "type": "string"
                },
                "operation": {
                  "type": "string"
                }
              },
              "required": [
                "code",
                "message",
                "action",
                "operation"
              ],
              "additionalProperties": {}
            }
          },
          "payload": {
            "type": "object",
            "properties": {
              "caption": {
                "type": "string"
              }
            },
            "required": [
              "caption"
            ],
            "additionalProperties": {}
          },
          "approvalUrl": {
            "type": "string"
          }
        },
        "required": [
          "itemId",
          "accountId",
          "accountName",
          "platform",
          "handle",
          "mediaId",
          "mediaName",
          "mediaStatus",
          "publicationId",
          "remoteId",
          "remoteUrl",
          "at",
          "timezone",
          "state",
          "confirmation",
          "problems",
          "payload"
        ],
        "additionalProperties": {}
      }
    }
  },
  "required": [
    "batchId",
    "projectId",
    "existing",
    "canApply",
    "entries"
  ],
  "additionalProperties": {}
}