{ "swagger": "2.0", "info": { "title": "ContentSafety Service", "version": "2023-04-30-preview", "description": "Analyze harmful content", "x-typespec-generated": [ { "emitter": "@azure-tools/typespec-autorest" } ] }, "schemes": [ "https" ], "x-ms-parameterized-host": { "hostTemplate": "{endpoint}/contentsafety", "useSchemePrefix": false, "parameters": [ { "name": "endpoint", "in": "path", "description": "Supported Cognitive Services endpoints (protocol and hostname, for example:\nhttps://.cognitiveservices.azure.com).", "required": true, "type": "string" } ] }, "produces": [ "application/json" ], "consumes": [ "application/json" ], "security": [ { "ApiKeyAuth": [] } ], "securityDefinitions": { "ApiKeyAuth": { "type": "apiKey", "name": "Ocp-Apim-Subscription-Key", "in": "header" } }, "tags": [], "paths": { "/image:analyze": { "post": { "operationId": "ImageOperations_AnalyzeImage", "summary": "Analyze Image", "description": "A sync API for harmful content analysis for image. Currently, we support four categories: Hate, SelfHarm, Sexual, Violence.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "body", "in": "body", "description": "The analysis request of the image.", "required": true, "schema": { "$ref": "#/definitions/AnalyzeImageOptions" } } ], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/AnalyzeImageResult" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Analyze Image": { "$ref": "./examples/AnalyzeImage.json" } } } }, "/text/blocklists": { "get": { "operationId": "TextBlocklists_ListTextBlocklists", "summary": "Get All Text Blocklists", "description": "Get all text blocklists details.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" } ], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedTextBlocklist" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Get All Text Blocklists": { "$ref": "./examples/ListTextBlocklists.json" } }, "x-ms-pageable": { "nextLinkName": "nextLink" } } }, "/text/blocklists/{blocklistName}": { "get": { "operationId": "TextBlocklists_GetTextBlocklist", "summary": "Get Text Blocklist By blocklistName", "description": "Returns text blocklist details.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "blocklistName", "in": "path", "description": "Text blocklist name.", "required": true, "type": "string", "maxLength": 64, "pattern": "^[0-9A-Za-z._~-]+$" } ], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/TextBlocklist" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Get Text Blocklist By blocklistName": { "$ref": "./examples/GetTextBlocklist.json" } } }, "patch": { "operationId": "TextBlocklists_CreateOrUpdateTextBlocklist", "summary": "Create Or Update Text Blocklist", "description": "Updates a text blocklist, if blocklistName does not exist, create a new blocklist.", "consumes": [ "application/merge-patch+json" ], "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "blocklistName", "in": "path", "description": "Text blocklist name.", "required": true, "type": "string", "maxLength": 64, "pattern": "^[0-9A-Za-z._~-]+$" }, { "name": "resource", "in": "body", "description": "The resource instance.", "required": true, "schema": { "$ref": "#/definitions/TextBlocklistCreateOrUpdate" } } ], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/TextBlocklist" } }, "201": { "description": "The request has succeeded and a new resource has been created as a result.", "schema": { "$ref": "#/definitions/TextBlocklist" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Create Or Update Text Blocklist": { "$ref": "./examples/CreateOrUpdateTextBlocklist.json" } } }, "delete": { "operationId": "TextBlocklists_DeleteTextBlocklist", "summary": "Delete Text Blocklist By blocklistName", "description": "Deletes a text blocklist.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "blocklistName", "in": "path", "description": "Text blocklist name.", "required": true, "type": "string", "maxLength": 64, "pattern": "^[0-9A-Za-z._~-]+$" } ], "responses": { "204": { "description": "There is no content to send for this request, but the headers may be useful. " }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Delete Text Blocklist By blocklistName": { "$ref": "./examples/DeleteTextBlocklist.json" } } } }, "/text/blocklists/{blocklistName}:addBlockItems": { "post": { "operationId": "TextBlocklists_AddBlockItems", "summary": "Add BlockItems To Text Blocklist", "description": "Add blockItems to a text blocklist. You can add at most 100 BlockItems in one request.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "blocklistName", "in": "path", "description": "Text blocklist name.", "required": true, "type": "string", "maxLength": 64, "pattern": "^[0-9A-Za-z._~-]+$" }, { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/AddBlockItemsOptions" } } ], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/AddBlockItemsResult" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Add BlockItems To Text Blocklist": { "$ref": "./examples/AddBlockItems.json" } } } }, "/text/blocklists/{blocklistName}:removeBlockItems": { "post": { "operationId": "TextBlocklists_RemoveBlockItems", "summary": "Remove BlockItems From Text Blocklist", "description": "Remove blockItems from a text blocklist. You can remove at most 100 BlockItems in one request.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "blocklistName", "in": "path", "description": "Text blocklist name.", "required": true, "type": "string", "maxLength": 64, "pattern": "^[0-9A-Za-z._~-]+$" }, { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/RemoveBlockItemsOptions" } } ], "responses": { "204": { "description": "There is no content to send for this request, but the headers may be useful. " }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Remove BlockItems From Text Blocklist": { "$ref": "./examples/RemoveBlockItems.json" } } } }, "/text/blocklists/{blocklistName}/blockItems": { "get": { "operationId": "TextBlocklists_ListTextBlocklistItems", "summary": "Get All BlockItems By blocklistName", "description": "Get all blockItems in a text blocklist", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "blocklistName", "in": "path", "description": "Text blocklist name.", "required": true, "type": "string", "maxLength": 64, "pattern": "^[0-9A-Za-z._~-]+$" }, { "$ref": "#/parameters/Azure.Core.TopQueryParameter" }, { "$ref": "#/parameters/Azure.Core.SkipQueryParameter" }, { "$ref": "#/parameters/Azure.Core.MaxPageSizeQueryParameter" } ], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedTextBlockItem" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Get All BlockItems By blocklistName": { "$ref": "./examples/ListTextBlocklistItems.json" } }, "x-ms-pageable": { "nextLinkName": "nextLink" } } }, "/text/blocklists/{blocklistName}/blockItems/{blockItemId}": { "get": { "operationId": "TextBlocklists_GetTextBlocklistItem", "summary": "Get BlockItem By blocklistName And blockItemId", "description": "Get blockItem By blockItemId from a text blocklist.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "blocklistName", "in": "path", "description": "Text blocklist name.", "required": true, "type": "string", "maxLength": 64, "pattern": "^[0-9A-Za-z._~-]+$" }, { "name": "blockItemId", "in": "path", "description": "Block Item Id. It will be uuid.", "required": true, "type": "string", "maxLength": 64 } ], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/TextBlockItem" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Get BlockItem By blocklistName And blockItemId": { "$ref": "./examples/GetTextBlocklistItem.json" } } } }, "/text:analyze": { "post": { "operationId": "TextOperations_AnalyzeText", "summary": "Analyze Text", "description": "A sync API for harmful content analysis for text. Currently, we support four categories: Hate, SelfHarm, Sexual, Violence.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "body", "in": "body", "description": "The request of text analysis.", "required": true, "schema": { "$ref": "#/definitions/AnalyzeTextOptions" } } ], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/AnalyzeTextResult" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, "headers": { "x-ms-error-code": { "type": "string", "description": "String error code indicating what went wrong." } } } }, "x-ms-examples": { "Analyze Text": { "$ref": "./examples/AnalyzeText.json" } } } } }, "definitions": { "AddBlockItemsOptions": { "type": "object", "description": "The request of adding blockItems to text blocklist.", "properties": { "blockItems": { "type": "array", "description": "Array of blockItemInfo to add.", "items": { "$ref": "#/definitions/TextBlockItemInfo" }, "x-ms-identifiers": [] } }, "required": [ "blockItems" ] }, "AddBlockItemsResult": { "type": "object", "description": "The response of adding blockItems to text blocklist.", "properties": { "value": { "type": "array", "description": "Array of blockItems added.", "items": { "$ref": "#/definitions/TextBlockItem" }, "x-ms-identifiers": [] } } }, "AnalyzeImageOptions": { "type": "object", "description": "The analysis request of the image.", "properties": { "image": { "$ref": "#/definitions/ImageData", "description": "The image needs to be analyzed." }, "categories": { "type": "array", "description": "The categories will be analyzed. If not assigned, a default set of the categories' analysis results will be returned.", "items": { "$ref": "#/definitions/ImageCategory" } } }, "required": [ "image" ] }, "AnalyzeImageResult": { "type": "object", "description": "The analysis response of the image.", "properties": { "hateResult": { "$ref": "#/definitions/ImageAnalyzeSeverityResult", "description": "Analysis result for Hate category." }, "selfHarmResult": { "$ref": "#/definitions/ImageAnalyzeSeverityResult", "description": "Analysis result for SelfHarm category." }, "sexualResult": { "$ref": "#/definitions/ImageAnalyzeSeverityResult", "description": "Analysis result for Sexual category." }, "violenceResult": { "$ref": "#/definitions/ImageAnalyzeSeverityResult", "description": "Analysis result for Violence category." } } }, "AnalyzeTextOptions": { "type": "object", "description": "The analysis request of the text.", "properties": { "text": { "type": "string", "description": "The text needs to be scanned. We support at most 1000 characters (unicode code points) in text of one request.", "maxLength": 1000 }, "categories": { "type": "array", "description": "The categories will be analyzed. If not assigned, a default set of the categories' analysis results will be returned.", "items": { "$ref": "#/definitions/TextCategory" } }, "blocklistNames": { "type": "array", "description": "The names of blocklists.", "items": { "type": "string" } }, "breakByBlocklists": { "type": "boolean", "description": "When set to true, further analyses of harmful content will not be performed in cases where blocklists are hit. When set to false, all analyses of harmful content will be performed, whether or not blocklists are hit." } }, "required": [ "text" ] }, "AnalyzeTextResult": { "type": "object", "description": "The analysis response of the text", "properties": { "blocklistsMatchResults": { "type": "array", "description": "The details of blocklist match.", "items": { "$ref": "#/definitions/TextBlocklistMatchResult" }, "x-ms-identifiers": [] }, "hateResult": { "$ref": "#/definitions/TextAnalyzeSeverityResult", "description": "Analysis result for Hate category." }, "selfHarmResult": { "$ref": "#/definitions/TextAnalyzeSeverityResult", "description": "Analysis result for SelfHarm category." }, "sexualResult": { "$ref": "#/definitions/TextAnalyzeSeverityResult", "description": "Analysis result for Sexual category." }, "violenceResult": { "$ref": "#/definitions/TextAnalyzeSeverityResult", "description": "Analysis result for Violence category." } } }, "Azure.Core.Foundations.Error": { "type": "object", "description": "The error object.", "properties": { "code": { "type": "string", "description": "One of a server-defined set of error codes." }, "message": { "type": "string", "description": "A human-readable representation of the error." }, "target": { "type": "string", "description": "The target of the error." }, "details": { "type": "array", "description": "An array of details about specific errors that led to this reported error.", "items": { "$ref": "#/definitions/Azure.Core.Foundations.Error" }, "x-ms-identifiers": [] }, "innererror": { "$ref": "#/definitions/Azure.Core.Foundations.InnerError", "description": "An object containing more specific information than the current object about the error." } }, "required": [ "code", "message" ] }, "Azure.Core.Foundations.ErrorResponse": { "type": "object", "description": "A response containing error details.", "properties": { "error": { "$ref": "#/definitions/Azure.Core.Foundations.Error", "description": "The error object." } }, "required": [ "error" ] }, "Azure.Core.Foundations.InnerError": { "type": "object", "description": "An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.", "properties": { "code": { "type": "string", "description": "One of a server-defined set of error codes." }, "innererror": { "$ref": "#/definitions/Azure.Core.Foundations.InnerError", "description": "Inner error." } } }, "ImageAnalyzeSeverityResult": { "type": "object", "description": "Image analysis result.", "properties": { "category": { "$ref": "#/definitions/ImageCategory", "description": "The image category." }, "severity": { "type": "integer", "format": "int32", "description": "The higher the severity of input content, the larger this value, currently its value could be: 0,2,4,6." } }, "required": [ "category", "severity" ] }, "ImageCategory": { "type": "string", "description": "Image analyze category", "enum": [ "Hate", "SelfHarm", "Sexual", "Violence" ], "x-ms-enum": { "name": "ImageCategory", "modelAsString": true } }, "ImageData": { "type": "object", "description": "The content or blob url of image, could be base64 encoding bytes or blob url. If both are given, the request will be refused. The maximum size of image is 2048 pixels * 2048 pixels, no larger than 4MB at the same time. The minimum size of image is 50 pixels * 50 pixels.", "properties": { "content": { "type": "string", "format": "byte", "description": "Base64 encoding of image." }, "blobUrl": { "type": "string", "format": "uri", "description": "The blob url of image." } } }, "PagedTextBlockItem": { "type": "object", "description": "Paged collection of TextBlockItem items", "properties": { "value": { "type": "array", "description": "The TextBlockItem items on this page", "items": { "$ref": "#/definitions/TextBlockItem" }, "x-ms-identifiers": [] }, "nextLink": { "type": "string", "format": "uri", "description": "The link to the next page of items" } }, "required": [ "value" ] }, "PagedTextBlocklist": { "type": "object", "description": "Paged collection of TextBlocklist items", "properties": { "value": { "type": "array", "description": "The TextBlocklist items on this page", "items": { "$ref": "#/definitions/TextBlocklist" }, "x-ms-identifiers": [] }, "nextLink": { "type": "string", "format": "uri", "description": "The link to the next page of items" } }, "required": [ "value" ] }, "RemoveBlockItemsOptions": { "type": "object", "description": "The request of removing blockItems from text blocklist.", "properties": { "blockItemIds": { "type": "array", "description": "Array of blockItemIds to remove.", "items": { "type": "string" } } }, "required": [ "blockItemIds" ] }, "TextAnalyzeSeverityResult": { "type": "object", "description": "Text analysis result.", "properties": { "category": { "$ref": "#/definitions/TextCategory", "description": "The text category." }, "severity": { "type": "integer", "format": "int32", "description": "The higher the severity of input content, the larger this value is. The values could be: 0,2,4,6." } }, "required": [ "category", "severity" ] }, "TextBlockItem": { "type": "object", "description": "Item in TextBlocklist.", "properties": { "blockItemId": { "type": "string", "description": "Block Item Id. It will be uuid.", "maxLength": 64, "x-ms-mutability": [ "read", "create" ] }, "description": { "type": "string", "description": "Block item description.", "maxLength": 1024 }, "text": { "type": "string", "description": "Block item content.", "maxLength": 128 } }, "required": [ "blockItemId", "text" ] }, "TextBlockItemInfo": { "type": "object", "description": "Block item info in text blocklist.", "properties": { "description": { "type": "string", "description": "Block item description.", "maxLength": 1024 }, "text": { "type": "string", "description": "Block item content.", "maxLength": 128 } }, "required": [ "text" ] }, "TextBlocklist": { "type": "object", "description": "Text Blocklist.", "properties": { "blocklistName": { "type": "string", "description": "Text blocklist name.", "maxLength": 64, "pattern": "^[0-9A-Za-z._~-]+$", "x-ms-mutability": [ "read", "create" ] }, "description": { "type": "string", "description": "Text blocklist description.", "maxLength": 1024 } }, "required": [ "blocklistName" ] }, "TextBlocklistCreateOrUpdate": { "type": "object", "description": "Text Blocklist.", "properties": { "blocklistName": { "type": "string", "description": "Text blocklist name.", "maxLength": 64, "pattern": "^[0-9A-Za-z._~-]+$", "x-ms-mutability": [ "read", "create" ] }, "description": { "type": "string", "description": "Text blocklist description.", "maxLength": 1024 } } }, "TextBlocklistMatchResult": { "type": "object", "description": "The result of blocklist match.", "properties": { "blocklistName": { "type": "string", "description": "The name of matched blocklist.", "maxLength": 64 }, "blockItemId": { "type": "string", "description": "The id of matched item.", "maxLength": 64 }, "blockItemText": { "type": "string", "description": "The content of matched item.", "maxLength": 128 }, "offset": { "type": "integer", "format": "int32", "description": "The character offset of matched text in original input." }, "length": { "type": "integer", "format": "int32", "description": "The length of matched text in original input." } }, "required": [ "blocklistName", "blockItemId", "blockItemText", "offset", "length" ] }, "TextCategory": { "type": "string", "description": "Text analyze category", "enum": [ "Hate", "SelfHarm", "Sexual", "Violence" ], "x-ms-enum": { "name": "TextCategory", "modelAsString": true } }, "Versions": { "type": "string", "enum": [ "2023-04-30-preview" ], "x-ms-enum": { "name": "Versions", "modelAsString": true, "values": [ { "name": "v2023_04_30_Preview", "value": "2023-04-30-preview" } ] } } }, "parameters": { "Azure.Core.Foundations.ApiVersionParameter": { "name": "api-version", "in": "query", "description": "The API version to use for this operation.", "required": true, "type": "string", "minLength": 1, "x-ms-parameter-location": "method", "x-ms-client-name": "apiVersion" }, "Azure.Core.MaxPageSizeQueryParameter": { "name": "maxpagesize", "in": "query", "description": "The maximum number of result items per page.", "required": false, "type": "integer", "format": "int32", "x-ms-parameter-location": "method" }, "Azure.Core.SkipQueryParameter": { "name": "skip", "in": "query", "description": "The number of result items to skip.", "required": false, "type": "integer", "format": "int32", "default": 0, "x-ms-parameter-location": "method" }, "Azure.Core.TopQueryParameter": { "name": "top", "in": "query", "description": "The number of result items to return.", "required": false, "type": "integer", "format": "int32", "x-ms-parameter-location": "method" } } }