Signing PDF documents
Upload a PDF document
The POST /v3/document endpoint is used to upload PDF documents before starting the signing process.
POST /v3/document
Authorization: Basic ${ base64(apiKey + ':' + secretKey) }
Content-Type: multipart/form-data; boundary=boundary
--boundary
Content-Disposition: form-data; name="my-file"; filename="my-file.pdf"
// File content
- curl
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
curl -u "$ACCOUNT_ID:$SECRET_KEY" https://api.idkollen.se/v3/document \
-F 'file=@contract.pdf;type=application/pdf'
var document = await client.Document.UploadAsync(File.ReadAllBytes("contract.pdf"), "contract.pdf");
final document = await client.document.upload(await File('contract.pdf').readAsBytes(), 'contract.pdf');
data, err := os.ReadFile("contract.pdf")
document, err := client.Document().Upload(ctx, data, "contract.pdf", "application/pdf")
import { readFile } from "node:fs/promises";
const document = await client.document().upload(await readFile("contract.pdf"), "contract.pdf");
var document = client.document().upload(Files.readAllBytes(Path.of("contract.pdf")), "contract.pdf").join();
$document = $client->document()->upload(file_get_contents('contract.pdf'), 'contract.pdf');
with open("contract.pdf", "rb") as file:
document = client.document().upload(file.read(), "contract.pdf")
document = client.document.upload(File.binread('contract.pdf'), 'contract.pdf')
let data = std::fs::read("contract.pdf")?;
let document = client.document().upload(data, "contract.pdf", "application/pdf").await?;
let data = try Data(contentsOf: URL(fileURLWithPath: "contract.pdf"))
let document = try await client.document.upload(data: data, filename: "contract.pdf")
Response:
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"hash": "..."
}
Start PDF sign
The POST /v3/bankid-no/sign endpoint is used to sign a document using BankID (NO).
POST /v3/bankid-no/sign
Authorization: Basic ${ base64(apiKey + ':' + secretKey) }
{
"documents": ["1668b9da-bff1-4dfc-ad48-60507b5a8d12"],
"refId": "12398698",
"redirectUrl": "https://..."
}
- curl
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
curl -u "$ACCOUNT_ID:$SECRET_KEY" https://api.idkollen.se/v3/bankid-no/sign \
-H 'Content-Type: application/json' \
-d '{
"redirectUrl": "https://example.com/return",
"documents": [
"1668b9da-bff1-4dfc-ad48-60507b5a8d12"
],
"refId": "12398698"
}'
var status = await client.BankIdNo.SignAsync(new BankIdNoSignRequest
{
RedirectUrl = "https://example.com/return",
Documents = ["1668b9da-bff1-4dfc-ad48-60507b5a8d12"],
RefId = "12398698",
});
final status = await client.bankIdNo.sign(const BankIdNoSignRequest(
redirectUrl: 'https://example.com/return',
documents: ['1668b9da-bff1-4dfc-ad48-60507b5a8d12'],
refId: '12398698',
));
// func ptr[T any](v T) *T { return &v }
status, err := client.BankIdNo().Sign(ctx, identisure.BankIdNoSignRequest{
RedirectUrl: ptr("https://example.com/return"),
Documents: []string{"1668b9da-bff1-4dfc-ad48-60507b5a8d12"},
RefId: ptr("12398698"),
})
const status = await client.bankidNo().sign({
redirectUrl: "https://example.com/return",
documents: ["1668b9da-bff1-4dfc-ad48-60507b5a8d12"],
refId: "12398698",
});
import com.identisure.client.models.*;
var status = client.bankIdNo().sign(new BankIdNoSignRequest()
.setRedirectUrl("https://example.com/return")
.setDocuments(List.of("1668b9da-bff1-4dfc-ad48-60507b5a8d12"))
.setRefId("12398698")
).join();
use Identisure\Client\Models\BankIdNo\BankIdNoSignRequest;
$status = $client->bankIdNo()->sign(new BankIdNoSignRequest(
redirectUrl: 'https://example.com/return',
documents: ['1668b9da-bff1-4dfc-ad48-60507b5a8d12'],
refId: '12398698',
));
from identisure_client.models import BankIdNoSignRequest
status = client.bankid_no().sign(
BankIdNoSignRequest(
redirect_url="https://example.com/return",
documents=["1668b9da-bff1-4dfc-ad48-60507b5a8d12"],
ref_id="12398698",
)
)
status = client.bank_id_no.sign(
Identisure::BankIdNo::SignRequest.new(
redirect_url: 'https://example.com/return',
documents: ['1668b9da-bff1-4dfc-ad48-60507b5a8d12'],
ref_id: '12398698',
)
)
use identisure_client::models::{BankIdNoSignRequest, Url};
let request = BankIdNoSignRequest::new()
.redirect_url(Url::parse("https://example.com/return")?)
.documents(vec!["1668b9da-bff1-4dfc-ad48-60507b5a8d12".to_owned()])
.ref_id("12398698");
let status = client.bankid_no().sign(request).await?;
let status = try await client.bankIdNo.sign(BankIdNoSignRequest(
redirectUrl: "https://example.com/return",
documents: ["1668b9da-bff1-4dfc-ad48-60507b5a8d12"],
refId: "12398698"
))
| Parameter | Required | Description |
|---|---|---|
| documents | Yes | An array of document ID's to sign. |
| refId | No | Reference ID which will be included in the result and in the redirect. |
| redirectUrl | No | Custom redirect URL, must be whitelisted. |
Response:
IDkollen will respond with HTTP status 201 for successful request, or 4xx/5xx on errors. For more information about errors, please see the Errors section.
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"refId": "12398698",
"status": "PENDING",
"url": "https://..."
}
| Property | Description |
|---|---|
| id | Authentication id, used to cancel or get the status of this sign request. |
| refId | The refId given in the request, if any. |
| url | The URL where the end user can sign. |
Fetch result
The GET /v3/bankid-no/sign/{{id}} endpoint is used to check the status of a sign request.
NOTE: This endpoint is rate limited to one request per second. See Errors.
GET /v3/bankid-no/sign/{{id}}
Authorization: Basic ${ base64(accountId + ':' + secretKey) }
- curl
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
curl -u "$ACCOUNT_ID:$SECRET_KEY" https://api.idkollen.se/v3/bankid-no/sign/$ID
var status = await client.BankIdNo.SignStatusAsync(id);
final status = await client.bankIdNo.signStatus(id);
status, err := client.BankIdNo().SignStatus(ctx, id)
const status = await client.bankidNo().signStatus(id);
var status = client.bankIdNo().signStatus(id).join();
$status = $client->bankIdNo()->signStatus($id);
status = client.bankid_no().sign_status(id)
status = client.bank_id_no.sign_status(id)
let status = client.bankid_no().sign_status(&id).await?;
let status = try await client.bankIdNo.signStatus(id: id)
This endpoint will respond with a HTTP status of 404 if the sign session has expired.
The status of a sign can be either one of: PENDING, COMPLETED or FAILED.
Pending
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"refId": "12398698",
"status": "PENDING"
}
| Parameter | Description |
|---|---|
| refId | The refId given in the request, if any. |
Completed
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"refId": "12398698",
"status": "COMPLETED",
"ssn": "YYYYMMDDXXXX",
"name": "Firstname Lastname",
"givenName": "Firstname",
"surname": "Lastname",
"birthDate": "1908-09-29",
"signedDocuments": [
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"hash": "..."
}
],
"pid": "9578-6000-4-1234567",
"bankId": "5e1b1e1f-3c2d-4a5b-8c9d-0e1f2a3b4c5d",
"signedAt": "2024-01-15T13:37:00Z"
}
| Parameter | Description |
|---|---|
| refId | The refId given in the request, if any. |
| ssn | The Norwegian personal identification number (11 digits) of the authenticated user. null if requestSsn was unset. |
| name | The full name of the signing user. |
| givenName | The given name of the signing user. |
| surname | The surname of the signing user. |
| birthDate | The birth date of the signing user (yyyy-MM-dd). |
| signedDocuments | Present for signs, an array of document ID's. |
| pid | A stable, pseudonymous BankID Personal Identifier (PID). Use this as the persistent key for a returning user - it does not change between logins. |
| bankId | BankID's unique identifier for the authenticated user. BankID may rotate it, so use it only within a single login, not as a stored key; use pid for a persistent key. |
| signedAt | The time the signing completed (ISO-8601). |
Failed
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"refId": "12398698",
"status": "FAILED",
"error": "INVALID_ID"
}
| Parameter | Description |
|---|---|
| refId | The refId given in the request, if any. |
| error | An error code describing the reason for why the sign failed. |
The error may be one of the following values:
| Code | Description |
|---|---|
| AUTH_FAILED | A generic code for any kind of failure. |
| CANCELLED | The authentication was cancelled either by the user or the partner. |
| INVALID_ID | The ID has expired or is otherwise invalid. |
| INTERNAL_ERROR | An internal error occurred causing the authentication to fail. |
| SESSION_TIMEOUT | The authentication expired or timed out. |
| UNSUPPORTED_CLIENT | The client used for the authentication is not supported. |
New error codes may be added in the future without prior notice. The partner should therefore handle unknown error codes in their implementations.
Fetch signed document
The GET /v3/document/{{id}} endpoint is used to receive a signed document.
GET /v3/document/{{id}}
Authorization: Basic ${ base64(accountId + ':' + secretKey) }
- curl
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
curl -u "$ACCOUNT_ID:$SECRET_KEY" https://api.idkollen.se/v3/document/$ID -o signed.pdf
var pdf = await client.Document.DownloadAsync(id);
final pdf = await client.document.download(id);
pdf, err := client.Document().Download(ctx, id)
const pdf = await client.document().download(id);
byte[] pdf = client.document().download(id).join();
$pdf = $client->document()->download($id);
pdf = client.document().download(id)
pdf = client.document.download(id)
let pdf = client.document().download(&id).await?;
let pdf = try await client.document.download(id: id)
Cancel signing
The DELETE /v3/bankid-no/sign/{{id}} endpoint is used to cancel an ongoing BankID (NO) signing.
DELETE /v3/bankid-no/sign/{{id}}
Authorization: Basic ${ base64(accountId + ':' + secretKey) }
- curl
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
curl -u "$ACCOUNT_ID:$SECRET_KEY" -X DELETE https://api.idkollen.se/v3/bankid-no/sign/$ID
await client.BankIdNo.CancelSignAsync(id);
await client.bankIdNo.cancelSign(id);
err := client.BankIdNo().CancelSign(ctx, id)
await client.bankidNo().cancelSign(id);
client.bankIdNo().cancelSign(id).join();
$client->bankIdNo()->cancelSign($id);
client.bankid_no().cancel_sign(id)
client.bank_id_no.cancel_sign(id)
client.bankid_no().cancel_sign(&id).await?;
try await client.bankIdNo.cancelSign(id: id)
IDkollen will respond with HTTP status 204 for successful request, or 4xx/5xx on errors. For more information about errors, please see the Errors section.