# Update a Signature Definition

# Alias

`DocumentSignerUpdate`

# Description

Modifies (updates) a signature definition of a document and signature definitions resource. Currently only the following modifications can be performed:

- Provide (or substitute) the signer's certificate, leaving all the other parameters that the signature already has, i.e., provide the value of the `parameters.certificate` property of the signature definition.

- Provide the parameters of the signature definition, completely replacing (where appropriate) the already defined parameters, i.e., provide the value of the `parameters` property of the signature definition.

- Provide the digital signature (PKCS #1) of the document to which the signature definition is applied, i.e., provide the value of the `signature` property of the signature definition.

- Provides the time-stamp of the signature that corresponds to the signature definition.

Important

After obtaining the hash of a document according to the signature definition, this definition can only be updated to incorporate the digital signature corresponding to the obtained hash or to incorporate the time-stamp of the signature to which the definition refers (the signature performed when the hash was requested via the obtain the hash of a signature for requesting a time-stamp operation, which would have put the digital signature in the definition of the signature before the requested hash was calculated). If a document and signature definitions resource contains several signature definition, between the obtaining of the hash and the update that adds the digital signature to the signature definition, none of the following tasks can be performed: the obtaining of the hash, the obtaining of the hash from the signature, the update that provides the digital signature or the update that incorporates the time-stamp in a different signature definition. The same restriction exists in the time interval between obtaining of the hash from the signature and the update that provides the time-stamp for the signature.

# Request

`PATCH /trustedx-resources/esignsp/v2/documents/{doc_and_sigdefs_id}/signers/{signature_definition_id}`

## Parameters

Name | Type | Usage | Description
`doc_and_sigdefs_id` | path | Required | Identifier of the document and signature definitions resource that contains the signature definition to be updated.
`signature_definition_id` | path | Required | Identifier of the signature definition to be updated.

## Authorization

The request must contain a bearer access token generated by an authorization server of the platform. This token must have a scope that includes the `urn:safelayer:eidas:sign:process:document` value, and it must be used as explained in RFC 6750. Basically, the access token must be included in an `Authorization` header as follows:

`Authorization: Bearer <token>`

The client application must obtain the required access token via a client credentials grant OAuth 2.0 interaction with the platform.

## Content-Type Header

`Content-Type: application/json`

## Body

Contains a JSON object with the following structure:

`{`
`"parameters" : {Parameters}`
`"signature" : {string},`
`"timestamps" : [{string}]`
`}`

The `parameters`, `signature` and `timestamps` properties are mutually exclusive and one or the other always has to be present.

Property | Usage | Description
`parameters` | Optional | Characteristics for extending or changing what is established by the signature policy of the signature definition. This property is optional but must be present if the `signature` and the `timestamps` properties are not.
`signature` | Optional | Digital signature (PKCS #1) of the document to which the signature definition is applied, encoded in base64. This property is optional but must be present if the `signature` and the `timestamps` properties are not.
`timestamps[]` | Optional | Time-stamps of signatures encoded in base64 (currently only one time-stamp can be specified). This property is optional but must be present if the `parameters` and the `signatureproperties` are not.

`Content-Type: application/json`
``
`{`
`"timestamps" : [`
`{`
`"type" : "rfc3161_timestamp_token",`
`"timestamp" : "MAAFADSFASDFASDF...="`
`}`
`}`

# Response

## Status-Line

Value | Description
`HTTP/1.1 204 No Content` | The signature definition was successfully updated and the response has no body.
`HTTP/1.1 409 Conflict` | An attempt was made to update a signature definition for which the hash of the document to which it will be applied was already obtained.
Others | See HTTP Response Status for all the possible cases.

## Body

If the signature definition is successfully updated, the response has no body. Otherwise, it will have a body containing a JSON object describing the error.