Skip to main content

Signature Management

Developers can set up a signature that will be automatically used when creating escrows with the autoSign parameter enabled. This allows you to automatically sign contracts as the seller without manual intervention.

Setting Up Your Signature

Before you can use the auto-sign feature, you need to upload your signature image to your developer account.
curl -X PUT https://dhmad.tn/developer/signature \
  -H "Authorization: Bearer your_developer_token" \
  -H "Content-Type: application/json" \
  -d '{
    "signatureImage": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
  }'
{
  "message": "Signature updated successfully",
  "hasSignature": true
}

Request Body

signatureImage
string
required
Base64 encoded signature image. Must be a valid image format (PNG, JPEG, JPG, GIF, or WEBP). The image should be in the format: data:image/[format];base64,[base64_encoded_data]

Checking Signature Status

You can check if you have a signature configured without retrieving the actual image.
curl -X GET https://dhmad.tn/developer/signature \
  -H "Authorization: Bearer your_developer_token"
{
  "hasSignature": true
}

Using Auto-Sign

Once you have set up your signature, you can enable auto-signing when creating escrows via the API by setting autoSign: true in the request body.
When autoSign is enabled, the contract will be automatically signed by the seller (you) using your stored signature. The buyer will still need to sign the contract manually.
If you enable autoSign but haven’t set up a signature, the escrow creation will fail with a 400 error. Make sure to set up your signature first.

Example: Creating an Escrow with Auto-Sign

JavaScript
const response = await fetch('https://dhmad.tn/api/v1/escrows', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sk_live_your_api_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    title: 'Web Development Service',
    amount: 1000.00,
    contractTerms: 'The seller agrees to deliver a fully functional website within 7 days.',
    buyerEmail: 'buyer@example.com',
    estimatedDeliveryDays: 7,
    autoSign: true  // Enable auto-signing
  })
});

const data = await response.json();
// Response will include contract.sellerSigned: true

Error Responses

400 Bad Request

Invalid Signature Format
{
  "error": "Bad Request",
  "message": "signatureImage must be a valid base64 encoded image (PNG, JPEG, JPG, GIF, or WEBP)"
}
Missing Signature Image
{
  "error": "Bad Request",
  "message": "signatureImage is required and must be a base64 encoded string"
}

401 Unauthorized

{
  "error": "Unauthorized"
}

Security Considerations

Your signature image is stored securely and is only used for auto-signing contracts when explicitly enabled via the autoSign parameter. The signature is never exposed in API responses for security reasons.
You can update your signature at any time by making another PUT request to /developer/signature. The new signature will be used for all future escrows created with autoSign: true.