{
	"openapi": "3.1.0",
	"info": {
		"title": "OKdokument API",
		"description": "OKdokument integration API",
		"contact": {
			"name": "Support",
			"email": "signatus.support@anasoft.com"
		},
		"version": "1.0"
	},
	"servers": [
		{
			"url": "http://localhost:8080",
			"description": "Generated server url"
		}
	],
	"paths": {
		"/JSON/upload": {
			"post": {
				"tags": [
					"json-sts-controller"
				],
				"summary": "Upload document (Multipart)",
				"description": "Uploads a document using multipart/form-data. Upload Service provides an alternative method for submitting documents to the system. While functionally similar to the Signature Request service. Parameter 'data' or 'dataText' contains JSON metadata.",
				"operationId": "upload",
				"requestBody": {
					"content": {
						"multipart/form-data": {
							"schema": {
								"$ref": "#/components/schemas/JSONUploadRequest"
							}
						}
					},
					"required": true
				},
				"responses": {
					"200": {
						"description": "Upload successful",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Result"
								}
							}
						}
					},
					"401": {
						"description": "Unauthorized",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"403": {
						"description": "Forbidden",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					}
				},
				"security": [
					{
						"apiKey": []
					}
				]
			}
		},
		"/JSON/signatureRequest": {
			"post": {
				"tags": [
					"json-sts-controller"
				],
				"summary": "Create signature request",
				"description": "Creates a new signature request with document content.",
				"operationId": "createSignatureRequest",
				"requestBody": {
					"content": {
						"application/json": {
							"schema": {
								"$ref": "#/components/schemas/JSONSignatureRequest"
							}
						}
					}
				},
				"responses": {
					"200": {
						"description": "Signature request created",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Result"
								}
							}
						}
					},
					"401": {
						"description": "Unauthorized",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"403": {
						"description": "Forbidden",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					}
				},
				"security": [
					{
						"apiKey": []
					}
				]
			}
		},
		"/JSON/document/{id}": {
			"get": {
				"tags": [
					"json-sts-controller"
				],
				"summary": "Download document",
				"description": "Downloads the document content as a byte array.",
				"operationId": "downloadFile",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Document content",
						"content": {
							"application/pdf": {}
						}
					},
					"401": {
						"description": "Unauthorized",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"403": {
						"description": "Forbidden",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"404": {
						"description": "Document not found",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					}
				},
				"security": [
					{
						"apiKey": []
					}
				]
			},
			"delete": {
				"tags": [
					"json-sts-controller"
				],
				"summary": "Delete document",
				"description": "Deletes the specified document.",
				"operationId": "deleteDocument",
				"parameters": [
					{
						"name": "id",
						"in": "path",
						"required": true,
						"schema": {
							"type": "string"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Document deleted successfully",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Result"
								}
							}
						}
					},
					"401": {
						"description": "Unauthorized",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"403": {
						"description": "Forbidden",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"404": {
						"description": "Document not found",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ErrorBody"
								}
							}
						}
					}
				},
				"security": [
					{
						"apiKey": []
					}
				]
			}
		}
	},
	"components": {
		"schemas": {
			"JSONSignatureRequestData": {
				"type": "object",
				"properties": {
					"signatureRequestId": {
						"type": "string",
						"description": "Unique identifier for the signature request"
					},
					"state": {
						"type": "string",
						"description": "The state of the document: tosign – document ready for signing, tags – pre-processing document, searching for tags and inserting signature acrofields, tostamp – pre-processing document, inserts digital stamp into document",
						"example": "tosign"
					},
					"resulturl": {
						"type": "string",
						"description": "URL to redirect the browser after finishing the signing process"
					},
					"sendInfoURL": {
						"type": "string",
						"description": "Info service provider by Portal application used for backed to backed communication after the document is submitted as signed or cancelled."
					},
					"allowedFields": {
						"type": "object",
						"additionalProperties": {
							"type": "string"
						},
						"description": "Defines acrofields that are allowed in document",
						"example": {
							"SIGNATURE": "_SO1_"
						}
					},
					"changeState": {
						"type": "string",
						"description": "Used to change state after finishing the round of signing: tosign"
					},
					"rules": {
						"type": "object",
						"additionalProperties": {},
						"description": "The signing process can be configured using rules.",
						"example": {
							"signAnywhereEnabled": false
						}
					},
					"sigData": {
						"type": "object",
						"additionalProperties": {},
						"description": "Parameter for storing secret information into encrypted part of signature directly in PDF structure.",
						"example": {
							"systemId": "1234567",
							"email": "johnsmith@gmail.com"
						}
					}
				}
			},
			"JSONUploadRequest": {
				"type": "object",
				"properties": {
					"file": {
						"type": "string",
						"format": "binary",
						"description": "The PDF document to be uploaded."
					},
					"dataText": {
						"$ref": "#/components/schemas/JSONSignatureRequestData",
						"description": "Signature Request Data in JSON format"
					}
				},
				"required": [
					"file"
				]
			},
			"Result": {
				"type": "object",
				"properties": {
					"message": {
						"type": "string"
					},
					"result": {},
					"url": {
						"type": "string"
					},
					"documentId": {
						"type": "string"
					}
				}
			},
			"ErrorBody": {
				"type": "object",
				"properties": {
					"message": {
						"type": "string"
					},
					"value": {},
					"tenant": {
						"type": "string"
					}
				}
			},
			"JSONFile": {
				"type": "object",
				"properties": {
					"content": {
						"type": "string",
						"description": "The binary content of the uploaded PDF file in base64 format. Maximal document size is 10 MB."
					},
					"filename": {
						"type": "string",
						"description": "Name of the document. This parameter is mandatory if you want to do the file conversion to PDF format. For conversion the file postfix must be: contract.doc or contract.docxc Name of the document with PDF postfix is also used in the email template."
					}
				},
				"required": [
					"content"
				]
			},
			"JSONSignatureRequest": {
				"type": "object",
				"properties": {
					"signatureRequestId": {
						"type": "string",
						"description": "Unique identifier for the signature request"
					},
					"state": {
						"type": "string",
						"description": "The state of the document: tosign – document ready for signing, tags – pre-processing document, searching for tags and inserting signature acrofields, tostamp – pre-processing document, inserts digital stamp into document",
						"example": "tosign"
					},
					"resulturl": {
						"type": "string",
						"description": "URL to redirect the browser after finishing the signing process"
					},
					"sendInfoURL": {
						"type": "string",
						"description": "Info service provider by Portal application used for backed to backed communication after the document is submitted as signed or cancelled."
					},
					"allowedFields": {
						"type": "object",
						"additionalProperties": {
							"type": "string"
						},
						"description": "Defines acrofields that are allowed in document",
						"example": {
							"SIGNATURE": "_SO1_"
						}
					},
					"changeState": {
						"type": "string",
						"description": "Used to change state after finishing the round of signing: tosign"
					},
					"rules": {
						"type": "object",
						"additionalProperties": {},
						"description": "The signing process can be configured using rules.",
						"example": {
							"signAnywhereEnabled": false
						}
					},
					"sigData": {
						"type": "object",
						"additionalProperties": {},
						"description": "Parameter for storing secret information into encrypted part of signature directly in PDF structure.",
						"example": {
							"systemId": "1234567",
							"email": "johnsmith@gmail.com"
						}
					},
					"filedata": {
						"$ref": "#/components/schemas/JSONFile",
						"description": "JSON Object of PDF file. This parameter must be empty if 'id' is filled."
					},
					"id": {
						"type": "string",
						"description": "Preloaded document id, used in the second round of signing, when the document is already in OKdokument temporary storage. When parameter id is filled, parameter filedata must be empty."
					}
				}
			}
		},
		"securitySchemes": {
			"apiKey": {
				"type": "apiKey",
				"name": "x-api-key",
				"in": "header"
			}
		}
	}
}