# Signed contracts ## **Create signed contract** To create a signed contract, use the following endpoint: `POST /api/SignedContract` ### **Input** ```json //POST /api/SignedContract { "contractGroupGuid": "d8b7fcd1-e607-4099-8d66-f27884dddb77", "externalID": "d8b7fcd1-e607-4099-8d66-f27884dddb77", "userIp": "string", "environment": 0, "templateVariant": "My variant name", "screenshot": "string", "clauses": [ { "tag": "my_tag", "accepted": true } ], "fieldCollection": { "name": "name", "surname": "surname" } } ``` | Field | Description | | --- | --- | | ContractGroupGuid | Contract group GUID connected to the signed contract | | ExternalId | The key used in your software that represents the user | | UserIp | The IP address | | Environment | 0: staging, 1: production | | TemplateVariant | The name of the template variant to use when generating the signed contract PDF file. If not provided, the "Default variant" will be used | | Screenshot | Byte array of an image corresponding to the contract. If the contract feature "Capture Screenshot" isn't enabled, this value will be ignored | | Clauses | The list of conditions set in the contract: | | Tag | The tag associated with the condition | | Accepted | Acceptance status of a single condition | | FieldCollection | A JSON where the recipient information is saved; the elements key must mirror what is saved in the contract Form Elements | ### **Output** ```json { "guid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "contract": { "version": "string", "enviroment": 0, "groupGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "nameOfContract": "string" }, "fieldCollection": "string", "signedContractDate": "2023-05-04T08:15:39.268Z", "platform": "string", "userIdentifier": "string", "clauses": [ { "tag": "my_tag", "accepted": true } ], "contractHash": "string", "externalID": "string", "signedContractGroupGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "userIp": "string", "contractGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6" } ``` | Field | Description | | --- | --- | | Guid | The auto generated signed contract guid | | Contract | The contract linked to the signed contract: | | Version | The version of the contract | | Environment | 0 = staging, 1 = production | | GroupGuid | Unique identifier that binds all the versions of a specific contract | | NameOfContract | Name of the contract | | FieldCollection | The same collection as input | | SignedContractDate | Creation date of the signed contract | | Platform | Platform on which the consent is created (API) | | UserIdentifier | Identifier of the user who has given the consent; it is automatically extracted from field collection if there's a field named "email" or "mail" or "e-mail", otherwise it will be saved as string empty | | Clauses | The same collection as input | | ContractHash | The hash that will be sent on the blockchain | | ExternalID | The same as input | | SignedContractGroupGuid | Auto generated guid | | UserIp | The IP of the user that created the signed contract | | ContractGuid | The guid of the contract linked to the signed contract | ## **Get signed contracts** To get the signed contracts, use the following endpoint: `POST /api/SignedContract/List` ### **Input** ```json //POST /api/SignedContract/List { "contractGroupGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "externalID": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "userIdentifier": "string", "dateFrom": "2020-04-01T00:00:00.0000000", "dateTo": "2030-04-01T00:00:00.0000000", "platform": "string", "enviroment": 0, "version": "string", "getScreenshot": true, "page": 1, "itemsPerPage": 20 } ``` | Field | Description | | --- | --- | | ContractGroupGuid | If set, retrieves the signed contract related to this specific contract group guid | | ExternalId | If set, retrieves the signed contracts related to this specific ExternalId | | UserIdentifier | If set, retrieves the signed contracts related to this UserIdentifier | | DateFrom | If set, retrieves the signed contracts created starting from this date | | DateTo | If set, retrieves the signed contracts created up to this date | | Platform | If set, retrieves the signed contracts of this specific platform | | Enviroment | If set, retrieves signed contracts of a specific environment (0: staging, 1: production) | | Version | If set, retrieves signed contracts related to a specific version | | Page | Pagination purpose, it must be > 0 | | ItemsPerPage | Pagination purpose, it must be > 0, it sets the number of elements retrieved by page | The only required parameters are `page` and `itemsPerPage`. The result collection doesn't include signed contracts related to deleted contracts. The result is a list of signed contracts. ### **Output** ```json [ { "guid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "contract": { "version": "string", "enviroment": 0, "groupGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "nameOfContract": "string" }, "fieldCollection": "string", "signedContractDate": "2023-05-04T13:23:08.277Z", "platform": "string", "userIdentifier": "string", "clauses": [ { "tag": "string", "accepted": true } ], "blockchainProcessId": "string", "blockchainTxHash": "string", "contractHash": "string", "blockchainStatus": 0, "blockchainStatusDate": "2023-05-04T13:23:08.277Z", "externalID": "string", "blockchainUuid": "string", "pdf": "string", "signedContractGroupGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "contractGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "userIp": "string", "screenshot": "string" } ] ``` | Field | Description | | --- | --- | | Guid | The auto generated signed contract guid | | Contract | The contract linked to the signed contract | | Contract.Version | The version of the contract | | Contract.Enviroment | 0 = staging, 1 = production | | Contract.GroupGuid | Unique identifier that binds all the versions of a specific contract | | Contract.NameOfContract | Name of the contract | | FieldCollection | The JSON given as input | | SignedContractDate | Creation date of the signed contract | | Platform | Platform on which the signed contract is created (Windows, Android, Macintosh, iPhone, iPad, BlackBerry, CrOS, Linux, Symbian, Others) | | UserIdentifier | Identifier of the user | | Clauses | The same collection as input | | BlockchainProcessId | The ID of the process on the blockchain | | BlockchainTxHash | The final hash that represents the success save on the blockchain | | ContractHash | The hash that will be sent on the blockchain | | BlockchainStatus | Save status on the blockchain (Registered = 0, Queued = 1, ProcessCreated = 2, Notarized = 3, Error = 4) | | BlockchainStatusDate | When the status of the save on the blockchain changes | | ExternalID | The same as input | | BlockchainUuid | UUID generated by the blockchain | | SignedContractGroupGuid | The signed contract group guid | | ContractGuid | The GUID of the contract linked to the signed contract | | UserIp | The IP of the user that created the signed contract | | Screenshot | The screenshot of the signed contract if present and if... | ## **Get signed contract PDF** To get the signed contract PDF document use the following endpoint: `GET /api/SignedContract/GetSignedContract/{signedContractGuid}` ### **Output** The signed contract PDF file ## **Get audit trail PDF** To get the audit trail PDF document, use the following endpoint: `GET /api/SignedContract/GetAuditTrail/{signedContractGuid}` ### **Output** The Audit Trail PDF file