Skip to main content
Certyneo
Advanced seal · eIDAS art. 36

Advanced electronic seal API, with your own key

Certyneo's advanced seal is applied in two steps with a key your organisation generates and keeps (HSM, key management service or protected file). You submit a certificate signing request (CSR), your legal representative signs a mandate amendment, then each seal takes two calls: prepare, then sign.

The private key stays with you

Certyneo receives a CSR, then one signature value per seal. Never the key.

One-year certificate, revocable

Issued in the legal name from the company register, listed in a revocation list (CRL) when revoked.

Timestamped PAdES-B-T

Every seal embeds an RFC 3161 timestamp token in the PDF.

What this seal does not give you

  • No green tick in PDF readers: the Certyneo authority is on neither the EU trusted list nor Adobe's. Readers show "validity unknown" until the verifier adds our root certificate.
  • No legal presumption of integrity and origin (eIDAS art. 35.2): that is reserved for qualified seals. An advanced seal is admissible, but whoever relies on it must show it is reliable.
  • Does not cover business-to-business e-invoices: for the seal route, art. 289 VII of the French tax code requires a qualified seal. The invoice_b2b purpose is refused.
  • Keeping the key is your responsibility: storage, backup, renewal, and reporting a compromise at once.

The advanced seal is opened organisation by organisation. Until it is open for yours, the routes in this guide refuse the request, and never downgrade it to a simple seal: 501 SEAL_LEVEL_NOT_AVAILABLE

Before you start

  • An active seal identity (registry checked, mandate signed by the legal representative), the right to seal (Business plan or above, or the electronic seal option) and an advanced seal certificate paid for on the Billing page before you submit the key. The identity's ID, which the API needs, is shown in the electronic seal settings
  • An API key with the permission seals:write
  • Your legal representative, reachable by email and SMS: they sign the amendment that names the key.

Enrol your organisation's key

Enrolment happens once per key, then at each renewal. It ties one specific key to your organisation's decision.

1.Generate the key pair

Accepted algorithms: ECDSA P-256 or P-384, RSA 2048 bits or more. Generate the key where it will stay: ideally in an HSM or a key management service; otherwise in a file with restricted permissions.

# ECDSA P-256 (recommended)
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out seal-key.pem

# or RSA 3072
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -out seal-key.pem

# The private key never leaves your infrastructure. Restrict access to it:
chmod 600 seal-key.pem

2.Request a challenge

The challenge is valid for 15 minutes and bound to your seal identity: an old CSR, or one made for another company, cannot be replayed.

curl -s -X POST https://certyneo.com/api/v1/seal-identities/<IDENTITY_ID>/keys/challenge \
  -H "Authorization: Bearer $CERTYNEO_API_KEY"
# → { "challenge": "ck1.1764079200.9f2c…", "attribute": "challengePassword", "expiresAt": "…" }

3.Create the certificate signing request (CSR)

The challenge goes in the challengePassword attribute of the CSR. It is an attribute, not an extension: with OpenSSL, set it in the req_attributes section of a configuration file. The CSR subject is ignored: the certificate carries the legal name from the company register.

# seal-csr.cnf
[req]
prompt             = no
distinguished_name = dn
attributes         = req_attributes

[dn]
# Ignored: the certificate carries the legal name from the company register.
CN = ignored

[req_attributes]
challengePassword = <CHALLENGE>
openssl req -new -key seal-key.pem -config seal-csr.cnf -sha256 -out seal.csr

Key in an HSM or a key management service: make the same CSR through its PKCS#11 interface; the private key never leaves the device.

# Key generated and kept in an HSM or key management service with a PKCS#11
# interface (OpenSSL 3 + pkcs11-provider). The private key stays in the device.
openssl req -new -provider pkcs11 -provider default \
  -key "pkcs11:token=seal;object=certyneo-seal;type=private" \
  -config seal-csr.cnf -sha256 -out seal.csr

4.Submit the CSR and have the amendment signed

The key becomes PENDING_MANDATE and a mandate amendment, printing the key fingerprint, is sent to your legal representative. As soon as they sign it with their SMS code, the one-year certificate is issued and the key becomes ACTIVE.

jq -Rs '{csr: .}' seal.csr | curl -s -X POST \
  https://certyneo.com/api/v1/seal-identities/<IDENTITY_ID>/keys \
  -H "Authorization: Bearer $CERTYNEO_API_KEY" \
  -H "Content-Type: application/json" -d @-
# → 201 { "id": "<KEY_ID>", "status": "PENDING_MANDATE",
#         "mandate": { "awaiting": "legal_representative_signature", … } }

# Once the legal representative has signed the amendment, the key is ACTIVE:
curl -s https://certyneo.com/api/v1/seal-identities/<IDENTITY_ID>/keys \
  -H "Authorization: Bearer $CERTYNEO_API_KEY" | jq '.data[] | {id, status, notAfter}'

Renewal: new key, new CSR, new amendment. Both keys coexist during the overlap. An email warns you 30 and then 7 days before expiry.

Apply a seal in two steps

Since the key stays with you, Certyneo cannot seal in a single call:

  1. POST /api/v1/seals with level=ADVANCED and keyId: Certyneo prepares the PDF and returns the exact bytes to sign (signing.signedAttributes). Nothing is sealed yet.
  2. You sign those bytes with your key, using SHA-256. ECDSA: DER or r‖s signature; RSA: PKCS#1 v1.5.
  3. Within 15 minutes, POST to signatureUrl (/api/v1/seals/…/signature): Certyneo verifies the signature against the key's certificate, timestamps it, embeds the seal and returns the PDF link.

From the command line

# Step 1 — prepare: Certyneo returns the exact bytes to sign.
curl -s -X POST https://certyneo.com/api/v1/seals \
  -H "Authorization: Bearer $CERTYNEO_API_KEY" \
  -F file=@contract.pdf -F level=ADVANCED -F purpose=internal_document \
  -F keyId=<KEY_ID> > prepared.json
SEAL_ID=$(jq -r .id prepared.json)
jq -r .signing.signedAttributes prepared.json | openssl base64 -d -A > signed-attributes.der

# Sign them with YOUR key (SHA-256). ECDSA output is DER, RSA is PKCS#1 v1.5.
openssl dgst -sha256 -sign seal-key.pem -out signature.der signed-attributes.der

# Step 2 — send the signature: Certyneo verifies it, timestamps and embeds the seal.
SIG=$(openssl base64 -A -in signature.der)
curl -s -X POST https://certyneo.com/api/v1/seals/$SEAL_ID/signature \
  -H "Authorization: Bearer $CERTYNEO_API_KEY" \
  -H "Content-Type: application/json" -d "{\"signature\":\"$SIG\"}" | jq -r .downloadUrl

With an HSM, sign through its PKCS#11 interface; a service that signs a pre-computed digest takes signing.signedAttributesSha256.

# Same signature from a PKCS#11 device:
openssl pkeyutl -sign -provider pkcs11 -provider default \
  -inkey "pkcs11:token=seal;object=certyneo-seal;type=private" \
  -digest sha256 -rawin -in signed-attributes.der -out signature.der

# A key management service that signs a pre-computed digest instead takes
# signing.signedAttributesSha256 (hex) with ECDSA-SHA-256 or RSA PKCS#1 v1.5 SHA-256.

Node.js

// seal.mjs — node seal.mjs contract.pdf
// Env: CERTYNEO_API_KEY, SEAL_KEY_ID, SEAL_PRIVATE_KEY (PEM file path).
import { readFile, writeFile } from "node:fs/promises";
import { createPrivateKey, sign } from "node:crypto";

const base = process.env.CERTYNEO_API_URL ?? "https://certyneo.com";
const auth = { Authorization: `Bearer ${process.env.CERTYNEO_API_KEY}` };
const input = process.argv[2] ?? "contract.pdf";

async function call(path, init) {
  const res = await fetch(base + path, { ...init, headers: { ...auth, ...init.headers } });
  const body = await res.json();
  if (!res.ok) throw new Error(`${res.status} ${body.details?.code ?? body.code}: ${body.error}`);
  return body;
}

// Step 1 — prepare. Nothing is sealed yet.
const form = new FormData();
form.append("file", new Blob([await readFile(input)], { type: "application/pdf" }), "contract.pdf");
form.append("level", "ADVANCED");
form.append("purpose", "internal_document");
form.append("keyId", process.env.SEAL_KEY_ID);
const prepared = await call("/api/v1/seals", { method: "POST", body: form });

// Sign the exact signedAttributes bytes with SHA-256 and YOUR key.
// ECDSA keys give a DER signature, RSA keys PKCS#1 v1.5 — both accepted.
// With an HSM or a key management service, sign here through its SDK instead.
const key = createPrivateKey(await readFile(process.env.SEAL_PRIVATE_KEY, "utf8"));
const signedAttributes = Buffer.from(prepared.signing.signedAttributes, "base64");
const signature = sign("sha256", signedAttributes, key);

// Step 2 — send the signature before prepared.signing.expiresAt (15 minutes).
// 503 SEAL_TIMESTAMP_UNAVAILABLE: send the SAME signature again a little later.
const sealed = await call(`/api/v1/seals/${prepared.id}/signature`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ signature: signature.toString("base64") }),
});

const pdf = Buffer.from(await (await fetch(sealed.downloadUrl)).arrayBuffer());
await writeFile("sealed.pdf", pdf);
console.log(sealed.id, sealed.status, sealed.sealedSha256);

Java

// Seal.java — java Seal.java contract.pdf   (JDK 17+)
// Env: CERTYNEO_API_KEY, SEAL_KEY_ID, SEAL_PRIVATE_KEY (PKCS#8 PEM file path).
import java.net.URI;
import java.net.http.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.*;
import java.util.regex.*;

public class Seal {
  static final String BASE = Optional.ofNullable(System.getenv("CERTYNEO_API_URL")).orElse("https://certyneo.com");
  static final HttpClient HTTP = HttpClient.newHttpClient();

  public static void main(String[] args) throws Exception {
    String auth = "Bearer " + System.getenv("CERTYNEO_API_KEY");
    byte[] pdf = Files.readAllBytes(Path.of(args.length > 0 ? args[0] : "contract.pdf"));

    // Step 1 — prepare (multipart/form-data).
    String boundary = "----certyneo" + UUID.randomUUID();
    var body = new java.io.ByteArrayOutputStream();
    for (String[] f : new String[][] {{"level", "ADVANCED"}, {"purpose", "internal_document"}, {"keyId", System.getenv("SEAL_KEY_ID")}}) {
      body.writeBytes(("--" + boundary + "\r\nContent-Disposition: form-data; name=\"" + f[0] + "\"\r\n\r\n" + f[1] + "\r\n").getBytes(StandardCharsets.UTF_8));
    }
    body.writeBytes(("--" + boundary + "\r\nContent-Disposition: form-data; name=\"file\"; filename=\"contract.pdf\"\r\nContent-Type: application/pdf\r\n\r\n").getBytes(StandardCharsets.UTF_8));
    body.writeBytes(pdf);
    body.writeBytes(("\r\n--" + boundary + "--\r\n").getBytes(StandardCharsets.UTF_8));
    String prepared = send(HttpRequest.newBuilder(URI.create(BASE + "/api/v1/seals"))
        .header("Authorization", auth).header("Content-Type", "multipart/form-data; boundary=" + boundary)
        .POST(HttpRequest.BodyPublishers.ofByteArray(body.toByteArray())).build(), 202);

    // Sign the exact signedAttributes bytes with SHA-256 and YOUR key.
    byte[] signedAttributes = Base64.getDecoder().decode(field(prepared, "signedAttributes"));
    PrivateKey key = loadKey(Files.readString(Path.of(System.getenv("SEAL_PRIVATE_KEY"))));
    Signature signer = Signature.getInstance(key.getAlgorithm().equals("EC") ? "SHA256withECDSA" : "SHA256withRSA");
    signer.initSign(key);
    signer.update(signedAttributes);
    String signature = Base64.getEncoder().encodeToString(signer.sign()); // ECDSA: DER

    // Step 2 — send the signature within 15 minutes.
    String sealed = send(HttpRequest.newBuilder(URI.create(BASE + "/api/v1/seals/" + field(prepared, "id") + "/signature"))
        .header("Authorization", auth).header("Content-Type", "application/json")
        .POST(HttpRequest.BodyPublishers.ofString("{\"signature\":\"" + signature + "\"}")).build(), 201);

    byte[] out = HTTP.send(HttpRequest.newBuilder(URI.create(field(sealed, "downloadUrl"))).build(),
        HttpResponse.BodyHandlers.ofByteArray()).body();
    Files.write(Path.of("sealed.pdf"), out);
    System.out.println(field(sealed, "id") + " " + field(sealed, "status"));
  }

  static String send(HttpRequest req, int expected) throws Exception {
    HttpResponse<String> res = HTTP.send(req, HttpResponse.BodyHandlers.ofString());
    if (res.statusCode() != expected) throw new IllegalStateException(res.statusCode() + " " + res.body());
    return res.body();
  }

  static PrivateKey loadKey(String pem) throws Exception {
    byte[] der = Base64.getMimeDecoder().decode(pem.replaceAll("-----[A-Z ]+-----", ""));
    for (String alg : new String[] {"EC", "RSA"}) {
      try { return KeyFactory.getInstance(alg).generatePrivate(new PKCS8EncodedKeySpec(der)); }
      catch (java.security.spec.InvalidKeySpecException e) { /* try the next algorithm */ }
    }
    throw new IllegalArgumentException("Expected an EC or RSA key in PKCS#8 PEM (openssl genpkey output)");
  }

  // Minimal reader for the string fields used here; use your JSON library in production.
  static String field(String json, String name) {
    Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
    if (!m.find()) throw new IllegalStateException("missing " + name + " in " + json);
    return m.group(1);
  }
}

.NET (C#)

// Program.cs — dotnet run -- contract.pdf   (.NET 6+)
// Env: CERTYNEO_API_KEY, SEAL_KEY_ID, SEAL_PRIVATE_KEY (PEM file path).
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Security.Cryptography;
using System.Text.Json;

var baseUrl = Environment.GetEnvironmentVariable("CERTYNEO_API_URL") ?? "https://certyneo.com";
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("CERTYNEO_API_KEY"));

// Step 1 — prepare. Nothing is sealed yet.
using var form = new MultipartFormDataContent();
var file = new ByteArrayContent(await File.ReadAllBytesAsync(args.Length > 0 ? args[0] : "contract.pdf"));
file.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
form.Add(file, "file", "contract.pdf");
form.Add(new StringContent("ADVANCED"), "level");
form.Add(new StringContent("internal_document"), "purpose");
form.Add(new StringContent(Environment.GetEnvironmentVariable("SEAL_KEY_ID")!), "keyId");
var prepared = await Send(await http.PostAsync($"{baseUrl}/api/v1/seals", form));

// Sign the exact signedAttributes bytes with SHA-256 and YOUR key.
var signedAttributes = Convert.FromBase64String(
    prepared.GetProperty("signing").GetProperty("signedAttributes").GetString()!);
var pem = await File.ReadAllTextAsync(Environment.GetEnvironmentVariable("SEAL_PRIVATE_KEY")!);
byte[] signature;
if (prepared.GetProperty("signing").GetProperty("signatureAlgorithm").GetString() == "ECDSA_SHA256")
{
    using var ec = ECDsa.Create();
    ec.ImportFromPem(pem);
    // .NET signs ECDSA in r||s (P1363) by default; DER and P1363 are both accepted.
    signature = ec.SignData(signedAttributes, HashAlgorithmName.SHA256, DSASignatureFormat.Rfc3279DerSequence);
}
else
{
    using var rsa = RSA.Create();
    rsa.ImportFromPem(pem);
    signature = rsa.SignData(signedAttributes, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
}

// Step 2 — send the signature within 15 minutes.
var id = prepared.GetProperty("id").GetString();
var sealed = await Send(await http.PostAsJsonAsync(
    $"{baseUrl}/api/v1/seals/{id}/signature", new { signature = Convert.ToBase64String(signature) }));

var pdf = await new HttpClient().GetByteArrayAsync(sealed.GetProperty("downloadUrl").GetString());
await File.WriteAllBytesAsync("sealed.pdf", pdf);
Console.WriteLine($"{sealed.GetProperty("id")} {sealed.GetProperty("status")}");

static async Task<JsonElement> Send(HttpResponseMessage res)
{
    var json = await res.Content.ReadFromJsonAsync<JsonElement>();
    if (!res.IsSuccessStatusCode) throw new Exception($"{(int)res.StatusCode} {json}");
    return json;
}

A refused signature (422 SEAL_SIGNATURE_INVALID) leaves the preparation open: send a corrected signature. If timestamping is briefly unavailable (503 SEAL_TIMESTAMP_UNAVAILABLE), send the same signature again a little later.

Seal in batches

Up to 25 documents per call, with the same key. Preparation is all or nothing; when signing, each seal succeeds or fails on its own, with its own code.

# Prepare up to 25 documents with the same key (all or nothing).
curl -s -X POST https://certyneo.com/api/v1/seals/batch \
  -H "Authorization: Bearer $CERTYNEO_API_KEY" \
  -F file=@a.pdf -F file=@b.pdf -F file=@c.pdf \
  -F purpose=internal_document -F keyId=<KEY_ID>
# → 202 { "seals": [ { "id", "signing": { "signedAttributes", … } }, … ] }

# Send every signature in one call; each seal succeeds or fails on its own.
curl -s -X POST https://certyneo.com/api/v1/seals/batch/signatures \
  -H "Authorization: Bearer $CERTYNEO_API_KEY" -H "Content-Type: application/json" \
  -d '{ "signatures": [ { "sealId": "…", "signature": "<base64>" }, … ] }'
# → 200 { "sealed": 2, "refused": 1,
#         "results": [ { "sealId", "status": 201, "seal": { … } },
#                      { "sealId", "status": 422, "error": { "code": "SEAL_SIGNATURE_INVALID", … } } ] }

Test mode

With a test API key (sk_test_*), the whole flow works without committing your organisation:

  • The certificate comes from a separate TEST authority, unrelated to the Certyneo root. Its name starts with [TEST] and it is never worth a production seal.
  • No amendment is sent: activation is simulated, the key is ACTIVE at once and the response says so (mandate.simulated = true).
  • A test key only seals in test, a production key only in production. The same key can be enrolled in test, then in production with a new CSR and a real amendment.
  • Test keys and seals are deleted with the rest of your test data, after 30 days or on request. A test seal has no proof certificate.

If test mode is not open for your account, a test key receives: 501 SEAL_KEY_SANDBOX_NOT_AVAILABLE

Revoke a key

A revoked key appears in the revocation list from the next read. Revocation is final. If you have any doubt about the key, revoke it with the keyCompromise reason, then enrol a new one.

curl -s -X POST https://certyneo.com/api/v1/seal-identities/<IDENTITY_ID>/keys/<KEY_ID>/revoke \
  -H "Authorization: Bearer $CERTYNEO_API_KEY" -H "Content-Type: application/json" \
  -d '{ "reason": "keyCompromise" }'

Error codes

Every refusal carries a stable code in details.code, which changes with neither the language nor the message text. Test that code.

CodeHTTPMeaning and what to do
SEAL_LEVEL_NOT_AVAILABLE501The advanced seal is not open for your organisation. Nothing was produced, nor downgraded to a simple seal.
SEAL_KEY_SANDBOX_NOT_AVAILABLE501Enrolment with a test key while test mode is not open. No key was enrolled.
SEAL_SANDBOX_NOT_AVAILABLE501Seal with a test key while test mode is not open. No seal was produced.
CSR_*422The CSR is refused: format, algorithm, key size, signature or missing challenge. Fix the CSR and submit it again.CSR_MALFORMED · CSR_UNSUPPORTED_SIGNATURE_ALGORITHM · CSR_KEY_UNREADABLE · CSR_KEY_ALGORITHM · CSR_KEY_TOO_SMALL · CSR_SIGNATURE_INVALID · CSR_CHALLENGE_MISSING
SEAL_KEY_CHALLENGE_EXPIRED422The challenge is more than 15 minutes old. Request a new one and redo the CSR.
SEAL_KEY_CHALLENGE_INVALID422The challenge does not match this seal identity.
SEAL_KEY_KEY_ALREADY_ENROLLED409This public key is already enrolled for this identity, in this environment.
SEAL_KEY_AMENDMENT_PENDING409Another key is awaiting the amendment signature. Wait for it, or revoke that key.
SEAL_CERTIFICATE_PAYMENT_REQUIRED402No paid advanced certificate is available: each certificate is paid for before it is issued, on the Billing page. No key was enrolled.
SEAL_KEY_NOT_ACTIVE409The key is not active: amendment not signed, key revoked or expired.
SEAL_PURPOSE_NOT_AVAILABLE422The advanced seal does not cover business-to-business invoices: art. 289 VII of the French tax code requires a qualified seal.
SEAL_SIGNATURE_INVALID422The signature does not verify against the key's certificate. Sign exactly signedAttributes, with SHA-256, using the enrolled key.
SEAL_PREPARATION_EXPIRED409More than 15 minutes between preparation and signature. Prepare the document again.
SEAL_TIMESTAMP_UNAVAILABLE503Timestamping did not answer. Nothing is sealed: send the same signature again after the Retry-After delay.
SEAL_MONTHLY_CEILING_REACHED429Monthly safety ceiling reached for this certificate: sealing resumes on the 1st of the following month. Write to us to raise it.

Go further