### Install and Start Mintlify CLI for Local Development Source: https://github.com/sajn-se/sajn-docs/blob/main/CLAUDE.md Installs the Mintlify CLI globally and starts the local development server to preview the documentation site. Updates will be reflected automatically. ```bash # Install Mintlify CLI globally (first time only) npm i -g mint # Start the local development server mint dev ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/sajn-se/sajn-docs/blob/main/README.md Installs the Mintlify CLI globally using npm. This tool is essential for previewing documentation changes locally. ```bash npm i -g mint ``` -------------------------------- ### Send Document for Signing Source: https://github.com/sajn-se/sajn-docs/blob/main/quickstart.mdx Sends a document to its designated signers via email or other configured delivery methods. ```APIDOC ## POST /api/v1/documents/{documentId}/send ### Description Sends a document to the signer(s) via email. ### Method POST ### Endpoint https://app.sajn.se/api/v1/documents/{documentId}/send ### Parameters #### Path Parameters - **documentId** (string) - Required - The ID of the document to send. #### Headers - **Authorization** (string) - Required - Bearer YOUR_API_KEY - **Content-Type** (string) - Required - application/json #### Request Body - **deliveryMethod** (string) - Required - The method for delivery (e.g., "EMAIL"). - **signatureType** (string) - Required - The type of signature expected (e.g., "DRAWING"). ### Request Example ```json { "deliveryMethod": "EMAIL", "signatureType": "DRAWING" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message that the document has been sent. #### Response Example ```json { "message": "Document sent successfully for signing." } ``` ``` -------------------------------- ### Create Document Source: https://github.com/sajn-se/sajn-docs/blob/main/quickstart.mdx Creates a new document in draft status within your Sajn account. This is the first step before adding signers or sending for signature. ```APIDOC ## POST /api/v1/documents ### Description Creates a new document in draft status. ### Method POST ### Endpoint https://app.sajn.se/api/v1/documents ### Parameters #### Headers - **Authorization** (string) - Required - Bearer YOUR_API_KEY - **Content-Type** (string) - Required - application/json #### Request Body - **name** (string) - Required - The name of the document. - **type** (string) - Required - The type of document (e.g., "SIGNABLE"). ### Request Example ```json { "name": "Employment Contract", "type": "SIGNABLE" } ``` ### Response #### Success Response (200) - **documentId** (string) - The unique identifier for the created document. - **name** (string) - The name of the document. - **type** (string) - The type of the document. #### Response Example ```json { "documentId": "DOC_456def", "name": "Employment Contract", "type": "SIGNABLE" } ``` ``` -------------------------------- ### Create Contact Source: https://github.com/sajn-se/sajn-docs/blob/main/quickstart.mdx Creates a new contact in your Sajn account. This contact can then be added as a signer to documents. ```APIDOC ## POST /api/v1/contacts ### Description Creates a new contact in your Sajn account. ### Method POST ### Endpoint https://app.sajn.se/api/v1/contacts ### Parameters #### Headers - **Authorization** (string) - Required - Bearer YOUR_API_KEY - **Content-Type** (string) - Required - application/json #### Request Body - **firstName** (string) - Required - The first name of the contact. - **lastName** (string) - Required - The last name of the contact. - **email** (string) - Required - The email address of the contact. ### Request Example ```json { "firstName": "John", "lastName": "Doe", "email": "john.doe@example.com" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created contact. - **firstName** (string) - The first name of the contact. - **lastName** (string) - The last name of the contact. - **email** (string) - The email address of the contact. #### Response Example ```json { "id": "CON_123abc", "firstName": "John", "lastName": "Doe", "email": "john.doe@example.com" } ``` ``` -------------------------------- ### API Pagination Response Example Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx An example of a paginated API response, including the requested data (e.g., 'documents') and metadata about the pagination, such as the total number of pages available. ```json { "documents": [...], "totalPages": 5 } ``` -------------------------------- ### Send a Document for Signing using cURL Source: https://github.com/sajn-se/sajn-docs/blob/main/quickstart.mdx This cURL command initiates the sending process for a document to its designated signer via email. It requires your API key and the document ID. You can specify the delivery method and the desired signature type. ```bash curl -X POST https://app.sajn.se/api/v1/documents/{documentId}/send \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "deliveryMethod": "EMAIL", "signatureType": "DRAWING" }' ``` -------------------------------- ### Create a Document using cURL Source: https://github.com/sajn-se/sajn-docs/blob/main/quickstart.mdx This cURL command creates a new document in a draft status within Sajn. You need to provide your API key and specify the document's name and type. The returned document ID is essential for further actions on the document. ```bash curl -X POST https://app.sajn.se/api/v1/documents \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Employment Contract", "type": "SIGNABLE" }' ``` -------------------------------- ### Create a Contact using cURL Source: https://github.com/sajn-se/sajn-docs/blob/main/quickstart.mdx This snippet demonstrates how to create a new contact in Sajn using a cURL command. It requires your API key and specifies the contact's first name, last name, and email. The returned contact ID is crucial for subsequent operations. ```bash curl -X POST https://app.sajn.se/api/v1/contacts \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "firstName": "John", "lastName": "Doe", "email": "john.doe@example.com" }' ``` -------------------------------- ### API Success Response Example Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx An example of a successful API response, typically returned for operations like creating or retrieving documents. It includes a unique identifier, name, status, and creation timestamp. ```json { "id": "doc_123", "name": "Employment Contract", "status": "DRAFT", "createdAt": "2024-01-15T10:00:00Z" } ``` -------------------------------- ### Run Mintlify Development Server Source: https://github.com/sajn-se/sajn-docs/blob/main/README.md Starts the Mintlify local development server. This command should be run from the root directory of your documentation project, where the 'docs.json' file is located. ```bash mint dev ``` -------------------------------- ### Complete Signer Information Example (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/concepts/signers.mdx Provides a comprehensive example of signer data, including personal and company details, role, and signing order. This structure is used for defining all aspects of a signer. ```json { "name": "John Doe", "email": "john@example.com", "phone": "+46701234567", "ssn": "197001011234", "companyName": "Acme Corp", "companyRole": "CEO", "companyOrgNumber": "556123-4567", "companyId": "company_id_123", "role": "SIGNER", "signingOrder": 1 } ``` -------------------------------- ### Add Signer to Document Source: https://github.com/sajn-se/sajn-docs/blob/main/quickstart.mdx Adds an existing contact as a signer to a specific document. You can assign roles to signers. ```APIDOC ## POST /api/v1/documents/{documentId}/signers ### Description Adds a contact as a signer to a document. ### Method POST ### Endpoint https://app.sajn.se/api/v1/documents/{documentId}/signers ### Parameters #### Path Parameters - **documentId** (string) - Required - The ID of the document to which the signer will be added. #### Headers - **Authorization** (string) - Required - Bearer YOUR_API_KEY - **Content-Type** (string) - Required - application/json #### Request Body - **contactId** (string) - Required - The ID of the contact to add as a signer. - **role** (string) - Required - The role of the signer (e.g., "SIGNER"). ### Request Example ```json { "contactId": "CON_123abc", "role": "SIGNER" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of the signer being added. #### Response Example ```json { "message": "Signer added successfully." } ``` ``` -------------------------------- ### Webhooks Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx Real-time notifications about document events can be received via webhooks. Refer to the Webhooks Guide for setup details. ```APIDOC ## Webhooks Receive real-time notifications about document events. See the [Webhooks Guide](/guides/webhooks) for details. ``` -------------------------------- ### Make Authenticated Request (Node.js, Python, PHP, Go) Source: https://github.com/sajn-se/sajn-docs/blob/main/authentication.mdx This section provides examples of making authenticated requests to the sajn API using different programming languages. Each example shows how to include the API key, typically stored in an environment variable, in the `Authorization` header. ```javascript const axios = require('axios'); const response = await axios.get('https://app.sajn.se/api/v1/documents', { headers: { 'Authorization': `Bearer ${process.env.SAJN_API_KEY}` } }); ``` ```python import requests import os response = requests.get( 'https://app.sajn.se/api/v1/documents', headers={'Authorization': f'Bearer {os.environ["SAJN_API_KEY"]}'} ) ``` ```php ``` ```go package main import ( "net/http" "os" ) func main() { client := &http.Client{} req, _ := http.NewRequest("GET", "https://app.sajn.se/api/v1/documents", nil) req.Header.Add("Authorization", "Bearer " + os.Getenv("SAJN_API_KEY")) resp, _ := client.Do(req) } ``` -------------------------------- ### Add a Signer to a Document using cURL Source: https://github.com/sajn-se/sajn-docs/blob/main/quickstart.mdx This snippet shows how to add an existing contact as a signer to a specific document using cURL. It requires your API key, the document ID, and the contact ID obtained from Step 1. It also defines the role of the contact in the signing process. ```bash curl -X POST https://app.sajn.se/api/v1/documents/{documentId}/signers \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contactId": "CONTACT_ID_FROM_STEP_1", "role": "SIGNER" }' ``` -------------------------------- ### Rate Limit Response Headers Example Source: https://github.com/sajn-se/sajn-docs/blob/main/authentication.mdx These are example HTTP response headers that indicate rate limiting information. They show the maximum number of requests allowed (`X-RateLimit-Limit`), the number of requests remaining (`X-RateLimit-Remaining`), and the timestamp when the limit resets (`X-RateLimit-Reset`). ```http X-RateLimit-Limit: 100 X-RateLimit-Remaining: 95 X-RateLimit-Reset: 1640000000 ``` -------------------------------- ### API Pagination Request Example Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx Shows how to utilize pagination for list endpoints by appending 'page' and 'perPage' query parameters to the request URL. This allows for efficient retrieval of large datasets. ```http GET /api/v1/documents?page=1&perPage=20 ``` -------------------------------- ### Sequential Signing Order Example (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/concepts/signers.mdx Illustrates how to set up a signing order for multiple signers using the 'signingOrder' field. This ensures documents are signed in a specific sequence. ```json { "signers": [ { "name": "Manager", "email": "manager@company.com", "role": "SIGNER", "signingOrder": 1 }, { "name": "Employee", "email": "employee@company.com", "role": "SIGNER", "signingOrder": 2 } ] } ``` -------------------------------- ### Signer Role Example (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/concepts/signers.mdx Demonstrates the structure for defining a signer with a specific role like 'SIGNER'. This is used when setting up participants for a document. ```json { "role": "SIGNER", "name": "John Doe", "email": "john@example.com" } ``` -------------------------------- ### API Error Handling Example Source: https://context7.com/sajn-se/sajn-docs/llms.txt This JavaScript code provides an example of how to handle errors when making API calls to Sajn. It includes a try-catch block to manage network issues and non-OK HTTP responses, throwing a descriptive error message. It uses the `fetch` API. ```javascript // Error handling example async function safeApiCall() { try { const response = await fetch('https://app.sajn.se/api/v1/documents/invalid_id', { headers: { 'Authorization': `Bearer ${API_KEY}` } }); if (!response.ok) { const error = await response.json(); throw new Error(`API Error (${response.status}): ${error.message}`); } return await response.json(); } catch (error) { console.error('Request failed:', error.message); throw error; } } ``` -------------------------------- ### MDX File Frontmatter Example Source: https://github.com/sajn-se/sajn-docs/blob/main/CLAUDE.md Required frontmatter for every MDX file, including title and description, used for SEO and navigation purposes. ```yaml --- title: "Page Title" description: "Concise description for SEO and navigation" --- ``` -------------------------------- ### Document Type Examples in JSON Source: https://github.com/sajn-se/sajn-docs/blob/main/concepts/documents.mdx Illustrates the JSON structure for defining different document types in sajn, including SIGNABLE and ACCEPTABLE. ```json { "name": "Employment Contract", "type": "SIGNABLE" } ``` ```json { "name": "Terms of Service", "type": "ACCEPTABLE" } ``` -------------------------------- ### Custom Message Configuration (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/guides/send-for-signing.mdx Example JSON showing how to include a personalized message within the signing invitation email. ```json { "deliveryMethod": "EMAIL", "signatureType": "DRAWING", "customMessage": "Hi John, please review and sign the updated employment contract. Let me know if you have any questions!" } ``` -------------------------------- ### Signer Signing URL and Token Example (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/concepts/signers.mdx Shows the structure of the response containing a unique signing URL and token for each signer. This is crucial for secure document access. ```json { "signerId": "signer_123", "token": "abc123...", "signingUrl": "https://app.sajn.se/sign/doc_123?token=abc123..." } ``` -------------------------------- ### Complete Document Creation Example (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/guides/create-document.mdx This comprehensive JSON payload demonstrates creating a business contract with multiple features including signers, expiration, metadata, external ID, and custom fields. It serves as a complete reference for advanced document creation. ```json { "name": "Service Agreement - Acme Corp", "type": "SIGNABLE", "externalId": "agreement_2024_001", "expiresAt": "2024-02-15T23:59:59Z", "documentMeta": { "subject": "Service Agreement for Your Review", "message": "Please review and sign this service agreement. Contact us if you have any questions.", "signingOrder": "SEQUENTIAL", "defaultSignatureType": "DRAWING", "distributionMethod": "EMAIL", "forceReadFullDocument": true, "showCommentsToSigners": true, "preferredLanguage": "sv", "validFrom": "2024-01-01T00:00:00Z", "validTo": "2024-12-31T23:59:59Z", "value": "500000" }, "signers": [ { "name": "Jane Manager", "email": "jane@company.com", "role": "SIGNER", "signingOrder": 1 }, { "name": "John Client", "email": "john@acme.com", "role": "SIGNER", "signingOrder": 2 } ], "customFields": [ { "customInputId": "project_name", "value": "Digital Transformation" }, { "customInputId": "department", "value": "IT" } ] } ``` -------------------------------- ### Document Status Response (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/guides/send-for-signing.mdx Example JSON response detailing document and signer statuses, including read and signing progress. ```json { "id": "doc_123", "status": "PENDING", "signers": [ { "name": "John Doe", "readStatus": "OPENED", "signingStatus": "NOT_SIGNED", "signedAt": null }, { "name": "Jane Manager", "readStatus": "READ", "signingStatus": "SIGNED", "signedAt": "2024-01-15T10:30:00Z" } ] } ``` -------------------------------- ### Linking Signer to Contact Example (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/concepts/signers.mdx Demonstrates how to link a signer to an existing contact in sajn using 'contactId'. This helps pre-fill signer information and track history. ```json { "contactId": "contact_123", "role": "SIGNER" } ``` -------------------------------- ### API Error Response Example Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx Illustrates a typical error response from the sajn API. It contains a 'message' field explaining the nature of the error, useful for debugging and handling failed requests. ```json { "message": "Document not found" } ``` -------------------------------- ### Webhook Event Handling Source: https://context7.com/sajn-se/sajn-docs/llms.txt Provides examples and structure for handling incoming webhook events, including signature verification. ```APIDOC ## Webhook Event Handling ### Description This section details how to handle incoming webhook events, including verifying the signature to ensure the request's authenticity and processing different event types. ### Common Webhook Payload Structure ```json { "event": "DOCUMENT_SIGNED", "timestamp": "2024-01-15T10:30:00Z", "organizationId": "org_123", "data": { "documentId": "doc_abc123", "documentName": "Employment Contract", "externalId": "contract_2024_001", "signerId": "signer_1", "signerEmail": "john@example.com", "signerName": "John Doe", "signedAt": "2024-01-15T10:30:00Z", "signatureType": "DRAWING" } } ``` ### Signature Verification (Express.js Example) ```javascript const express = require('express'); const crypto = require('crypto'); const app = express(); app.use(express.json()); app.post('/webhooks/sajn', (req, res) => { // Verify webhook signature const signature = req.headers['x-sajn-signature']; const expectedSignature = crypto .createHmac('sha256', process.env.WEBHOOK_SECRET) .update(JSON.stringify(req.body)) .digest('hex'); if (signature !== expectedSignature) { return res.status(401).send('Invalid signature'); } // Process webhook event const { event, data, timestamp } = req.body; switch (event) { case 'DOCUMENT_SIGNED': console.log(`Document ${data.documentId} signed by ${data.signerName}`); break; case 'DOCUMENT_COMPLETED': console.log(`Document ${data.documentId} fully executed`); break; case 'DOCUMENT_REJECTED': console.log(`Document ${data.documentId} rejected by ${data.signerName}`); break; case 'SAJN_ID_VERIFIED': console.log(`Identity verified: ${data.fullName}`); break; } res.status(200).send('OK'); }); app.listen(3000); ``` ### Signature Verification (Flask Example) ```python from flask import Flask, request, abort import hmac import hashlib import json import os app = Flask(__name__) @app.route('/webhooks/sajn', methods=['POST']) def webhook(): # Verify signature signature = request.headers.get('X-Sajn-Signature') body = request.get_data() expected = hmac.new( bytes(os.environ['WEBHOOK_SECRET'], 'utf-8'), body, hashlib.sha256 ).hexdigest() if signature != expected: abort(401) # Process webhook payload = request.json event = payload['event'] data = payload['data'] if event == 'DOCUMENT_SIGNED': print(f"Document {data['documentId']} signed by {data['signerName']}") elif event == 'DOCUMENT_COMPLETED': print(f"Document {data['documentId']} completed") elif event == 'SAJN_ID_VERIFIED': print(f"Identity verified: {data['fullName']}") return 'OK', 200 if __name__ == '__main__': app.run(port=3000) ``` ``` -------------------------------- ### GET /api/v1/documents/{documentId}/download Source: https://github.com/sajn-se/sajn-docs/blob/main/guides/send-for-signing.mdx Downloads the final, sealed document after all parties have signed. ```APIDOC ## GET /api/v1/documents/{documentId}/download ### Description Downloads the final, sealed document after all parties have signed. ### Method GET ### Endpoint `/api/v1/documents/{documentId}/download` ### Parameters #### Path Parameters - **documentId** (string) - Required - The ID of the completed document to download. #### Query Parameters None. #### Request Body None. ### Request Example (No request body needed for GET requests) ### Response #### Success Response (200) - **File** (binary) - The signed and sealed document file (e.g., PDF). #### Response Example (The response will be the binary content of the document file.) ``` -------------------------------- ### Example Customer Onboarding Verification Request (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/concepts/sajn-id.mdx A JSON payload for a customer onboarding use case, requiring SSN-based verification. It includes name, SSN, email, channel, a unique reference, an optional note, and a flag to send immediately. ```json { "fullName": "John Doe", "ssn": "197001011234", "email": "john@example.com", "channel": "EMAIL", "reference": "account_signup", "note": "New customer registration", "sendImmediately": true } ``` -------------------------------- ### API Timestamp Format Example Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx Demonstrates the ISO 8601 format with UTC timezone used for all timestamp values in API responses, including creation and update times. This ensures consistency and ease of parsing. ```json { "createdAt": "2024-01-15T10:30:00Z", "updatedAt": "2024-01-15T11:45:00Z" } ``` -------------------------------- ### Get Document Details - API Source: https://context7.com/sajn-se/sajn-docs/llms.txt Retrieve comprehensive details for a specific document, including information about all signers and their current status. This is useful for tracking the progress of a document. ```bash # Get specific document curl https://app.sajn.se/api/v1/documents/doc_abc123 \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Error Response Example (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/authentication.mdx This JSON object represents a typical error response from the sajn API when authentication fails due to an invalid or missing API key. It indicates a `401 Unauthorized` status. ```json { "message": "Invalid or missing API key" } ``` -------------------------------- ### Complete BankID Verification Workflow Source: https://context7.com/sajn-se/sajn-docs/llms.txt A JavaScript example demonstrating how to create a BankID verification request and then poll for its completion status. It uses `fetch` to make API calls and handles verification states like SENT, VERIFIED, FAILED, EXPIRED, or CANCELED. Requires a valid API key. ```javascript // Complete verification workflow with polling async function verifyIdentity(fullName, email) { // Step 1: Create verification const createResponse = await fetch('https://app.sajn.se/api/v1/sajn-id', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ fullName, email, channel: 'EMAIL', reference: `signup_${Date.now()}`, sendImmediately: true }) }); const verification = await createResponse.json(); // Step 2: Poll for completion return new Promise((resolve, reject) => { const interval = setInterval(async () => { const statusResponse = await fetch( `https://app.sajn.se/api/v1/sajn-id/${verification.id}`, { headers: { 'Authorization': `Bearer ${API_KEY}` } } ); const status = await statusResponse.json(); if (status.status === 'VERIFIED') { clearInterval(interval); resolve(status); } else if (['FAILED', 'EXPIRED', 'CANCELED'].includes(status.status)) { clearInterval(interval); reject(new Error(`Verification ${status.status.toLowerCase()}`)); } }, 3000); // Poll every 3 seconds }); } // Usage try { const result = await verifyIdentity('John Doe', 'john@example.com'); console.log('Verification successful:', result.data); } catch (error) { console.error('Verification failed:', error); } ``` -------------------------------- ### Customer Onboarding Verification Payload (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/guides/identity-verification.mdx Example JSON payload for creating a customer onboarding verification request using sajn ID. This includes full name, SSN, email, communication channel, an optional reference, note, and immediate sending flag. ```json { "fullName": "John Doe", "ssn": "197001011234", "email": "john@example.com", "channel": "EMAIL", "reference": "customer_signup_2024_001", "note": "New customer registration", "sendImmediately": true } ``` -------------------------------- ### SDKs and Tools Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx Information about available SDKs, OpenAPI specification, and Postman integration. ```APIDOC ## SDKs and Tools - **TypeScript**: Full type safety with our OpenAPI specification - **OpenAPI Spec**: Available at `/api/v1/openapi` - **Postman**: Import our OpenAPI spec into Postman ``` -------------------------------- ### Update Mintlify CLI Source: https://github.com/sajn-se/sajn-docs/blob/main/README.md Updates the Mintlify CLI to the latest version. This is a troubleshooting step to ensure you have the most recent tools for development. ```bash mint update ``` -------------------------------- ### API Base URL Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx All API requests should be made to the following base URL. ```APIDOC ## Base URL All API requests should be made to: ``` https://app.sajn.se/api/v1 ``` ``` -------------------------------- ### Authentication Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx All API requests require authentication using an API key. Include your API key in the `Authorization` header. ```APIDOC ## Authentication All API requests require authentication using an API key. Include your API key in the `Authorization` header: ```bash curl https://app.sajn.se/api/v1/documents \ -H "Authorization: Bearer YOUR_API_KEY" ``` Get your API key from **Organization Settings > API Keys** in the [sajn dashboard](https://app.sajn.se). ``` -------------------------------- ### GET /api/v1/sajn-id/{verificationId} - Get Verification Status Source: https://github.com/sajn-se/sajn-docs/blob/main/guides/identity-verification.mdx Retrieves the current status and details of a specific identity verification request using its unique ID. This is useful for polling or checking the progress of a verification. ```APIDOC ## GET /api/v1/sajn-id/{verificationId} ### Description Retrieves the status and details of a specific identity verification request. ### Method GET ### Endpoint /api/v1/sajn-id/{verificationId} ### Parameters #### Path Parameters - **verificationId** (string) - Required - The unique ID of the verification request. #### Query Parameters None #### Request Body None ### Request Example ```bash GET /api/v1/sajn-id/verify_123 ``` ### Response #### Success Response (200) - **id** (string) - The unique ID of the verification request. - **status** (string) - The current status of the verification (e.g., "SENT", "VERIFIED", "FAILED"). - **fullName** (string) - The full name provided for verification. - **email** (string) - The email address used for verification. - **usedAt** (string) - Timestamp when the verification was completed (null if not completed). - **data** (object) - Contains completion data if the verification is successful. - **completionData** (object) - Details about the completed verification. - **user** (object) - Information about the verified user. - **personalNumber** (string) - The verified Swedish personal number. - **name** (string) - The full verified name. - **givenName** (string) - The verified given name. - **surname** (string) - The verified surname. #### Response Example (Pending) ```json { "id": "verify_123", "status": "SENT", "fullName": "John Doe", "email": "john@example.com", "usedAt": null } ``` #### Response Example (Completed) ```json { "id": "verify_123", "status": "VERIFIED", "fullName": "John Doe", "email": "john@example.com", "usedAt": "2024-01-15T10:30:00Z", "data": { "completionData": { "user": { "personalNumber": "197001011234", "name": "John Doe", "givenName": "John", "surname": "Doe" } } } } ``` ``` -------------------------------- ### SSN-Based Verification Payload Example (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/guides/identity-verification.mdx Example JSON structure for performing SSN-based identity verification with sajn ID. This method verifies both the individual's identity and their Swedish personal number, suitable for sensitive applications. ```json { "fullName": "John Doe", "ssn": "197001011234", "email": "john@example.com", "channel": "EMAIL" } ``` -------------------------------- ### GET /api/v1/contacts Source: https://context7.com/sajn-se/sajn-docs/llms.txt Retrieves a list of all contacts within the organization. ```APIDOC ## GET /api/v1/contacts ### Description Retrieves a list of all contacts associated with the authenticated organization. ### Method GET ### Endpoint https://app.sajn.se/api/v1/contacts ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl https://app.sajn.se/api/v1/contacts \ -H "Authorization: Bearer YOUR_API_KEY" ``` ### Response #### Success Response (200) - **contacts** (array) - A list of contact objects. - Each object contains: - **id** (string) - The unique identifier for the contact. - **firstName** (string) - The first name of the contact. - **lastName** (string) - The last name of the contact. - **email** (string) - The email address of the contact. - **phone** (string) - The phone number of the contact. - **company** (object) - Details of the associated company. - **id** (string) - The company ID. - **name** (string) - The company name. - **orgNumber** (string) - The company organization number. #### Response Example ```json { "contacts": [ { "id": "contact_abc123", "firstName": "John", "lastName": "Doe", "email": "john@example.com", "phone": "+46701234567", "company": { "id": "company_xyz789", "name": "Acme Corp", "orgNumber": "556123-4567" } } ] } ``` ``` -------------------------------- ### Pagination Source: https://github.com/sajn-se/sajn-docs/blob/main/api-reference/introduction.mdx List endpoints support pagination using query parameters for efficient data retrieval. ```APIDOC ## Pagination List endpoints support pagination with query parameters: ```bash GET /api/v1/documents?page=1&perPage=20 ``` Response includes pagination info: ```json { "documents": [...], "totalPages": 5 } ``` ``` -------------------------------- ### GET /api/v1/documents/{documentId} Source: https://github.com/sajn-se/sajn-docs/blob/main/guides/send-for-signing.mdx Retrieves the status of a specific document and its signers. ```APIDOC ## GET /api/v1/documents/{documentId} ### Description Retrieves the status of a specific document and its signers. ### Method GET ### Endpoint `/api/v1/documents/{documentId}` ### Parameters #### Path Parameters - **documentId** (string) - Required - The ID of the document to retrieve. #### Query Parameters None. #### Request Body None. ### Request Example (No request body needed for GET requests) ### Response #### Success Response (200) - **id** (string) - The document ID. - **status** (string) - The current status of the document (e.g., `PENDING`, `COMPLETED`). - **signers** (array) - An array of signer objects, each containing: - **name** (string) - The name of the signer. - **readStatus** (string) - The read status of the document for the signer (e.g., `OPENED`, `READ`). - **signingStatus** (string) - The signing status for the signer (e.g., `NOT_SIGNED`, `SIGNED`). - **signedAt** (string) - The timestamp when the signer signed (ISO 8601 format), or null if not signed. #### Response Example ```json { "id": "doc_123", "status": "PENDING", "signers": [ { "name": "John Doe", "readStatus": "OPENED", "signingStatus": "NOT_SIGNED", "signedAt": null }, { "name": "Jane Manager", "readStatus": "READ", "signingStatus": "SIGNED", "signedAt": "2024-01-15T10:30:00Z" } ] } ``` ``` -------------------------------- ### GET /api/v1/sajn-id/{verificationId} Source: https://context7.com/sajn-se/sajn-docs/llms.txt Retrieves the current status and results of a specific identity verification request. ```APIDOC ## GET /api/v1/sajn-id/{verificationId} ### Description Fetches the current status and results of a previously initiated identity verification request. ### Method GET ### Endpoint https://app.sajn.se/api/v1/sajn-id/{verificationId} ### Parameters #### Path Parameters - **verificationId** (string) - Required - The unique identifier of the verification request. #### Query Parameters None #### Request Body None ### Request Example ```bash curl https://app.sajn.se/api/v1/sajn-id/verify_abc123 \ -H "Authorization: Bearer YOUR_API_KEY" ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the verification request. - **status** (string) - The current status of the verification (e.g., "PENDING", "VERIFIED", "FAILED", "EXPIRED", "CANCELED"). - **fullName** (string) - The full name provided for verification. - **email** (string) - The email address used for the verification. - **reference** (string) - The reference provided for the verification. - **verificationUrl** (string) - The URL for the verification. - **createdAt** (string) - Timestamp of when the verification was created. - **updatedAt** (string) - Timestamp of when the verification was last updated. - **verifiedAt** (string, optional) - Timestamp of when the verification was successfully completed. - **failureReason** (string, optional) - Reason for verification failure, if applicable. - **identityData** (object, optional) - Verified identity data, if available. - **firstName** (string) - **lastName** (string) - **ssn** (string) - **dateOfBirth** (string) - **address** (object) - **street** - **zipCode** - **city** - **country** #### Response Example (Verified) ```json { "id": "verify_abc123", "status": "VERIFIED", "fullName": "John Doe", "email": "john@example.com", "reference": "customer_signup_2024_001", "verificationUrl": "https://app.sajn.se/verify/verify_abc123?token=token_xyz", "createdAt": "2024-01-15T10:00:00Z", "updatedAt": "2024-01-15T10:05:00Z", "verifiedAt": "2024-01-15T10:05:00Z", "identityData": { "firstName": "John", "lastName": "Doe", "ssn": "197001011234", "dateOfBirth": "1970-01-01", "address": { "street": "Example Street 1", "zipCode": "12345", "city": "Example City", "country": "SE" } } } ``` #### Response Example (Failed) ```json { "id": "verify_xyz789", "status": "FAILED", "fullName": "Jane Doe", "email": "jane@example.com", "reference": "age_check_002", "verificationUrl": "https://app.sajn.se/verify/verify_xyz789?token=token_abc", "createdAt": "2024-01-15T11:00:00Z", "updatedAt": "2024-01-15T11:01:00Z", "failureReason": "Name mismatch" } ``` ``` -------------------------------- ### Get Document Details Source: https://context7.com/sajn-se/sajn-docs/llms.txt Retrieves detailed information for a specific document, including signer status. ```APIDOC ## GET /api/v1/documents/{documentId} ### Description Retrieves complete document information including all signers and their status. ### Method GET ### Endpoint /api/v1/documents/{documentId} ### Path Parameters - **documentId** (string) - Required - The unique identifier of the document. ### Request Example ```bash curl https://app.sajn.se/api/v1/documents/doc_abc123 \ -H "Authorization: Bearer YOUR_API_KEY" ``` ### Response #### Success Response (200) - **id** (string) - Document ID. - **name** (string) - Document name. - **status** (string) - Current status of the document (e.g., PENDING). - **signers** (array) - List of signer objects with their status. #### Response Example ```json { "id": "doc_abc123", "name": "Employment Contract", "status": "PENDING", "signers": [ { "id": "signer_1", "name": "John Doe", "email": "john@example.com", "role": "SIGNER", "signingOrder": 1, "readStatus": "OPENED", "signingStatus": "NOT_SIGNED", "signedAt": null }, { "id": "signer_2", "name": "Jane Manager", "email": "jane@company.com", "role": "SIGNER", "signingOrder": 2, "readStatus": "READ", "signingStatus": "SIGNED", "signedAt": "2024-01-15T10:30:00Z" } ] } ``` ``` -------------------------------- ### Sequential Signing Configuration (JSON) Source: https://github.com/sajn-se/sajn-docs/blob/main/guides/send-for-signing.mdx JSON configurations for sequential signing, where signers must complete in a specified order. Includes document metadata, signer order definition, and sending payload. ```json // Document metadata (set when creating/updating document) { "documentMeta": { "signingOrder": "SEQUENTIAL" } } // Signers with order [ { "name": "Manager", "email": "manager@company.com", "signingOrder": 1 }, { "name": "Employee", "email": "employee@company.com", "signingOrder": 2 } ] // When sending { "deliveryMethod": "EMAIL", "signatureType": "DRAWING" } ``` -------------------------------- ### Authentication Source: https://context7.com/sajn-se/sajn-docs/llms.txt All API requests require Bearer token authentication in the Authorization header. This section provides examples for authenticating requests. ```APIDOC ## Authentication All API requests require Bearer token authentication in the Authorization header. ### Request Example (cURL) ```bash curl https://app.sajn.se/api/v1/health -H "Authorization: Bearer YOUR_API_KEY" ``` ### Response Example (Success) ```json { "status": "ok", "timestamp": "2024-01-15T10:00:00Z", "version": "1.0.0" } ``` ``` -------------------------------- ### Create a Document (Bash, JavaScript) Source: https://context7.com/sajn-se/sajn-docs/llms.txt Enables the creation of new digital documents within the sajn platform. Allows specifying document details, signers, metadata, and custom fields. The response includes document and signer IDs, along with unique signing URLs. ```bash # Basic document creation curl -X POST https://app.sajn.se/api/v1/documents \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Employment Contract - John Doe", "type": "SIGNABLE", "externalId": "contract_2024_001", "expiresAt": "2024-02-15T23:59:59Z", "signers": [ { "name": "John Doe", "email": "john@example.com", "role": "SIGNER", "signingOrder": 1 }, { "name": "Jane Manager", "email": "jane@company.com", "role": "SIGNER", "signingOrder": 2 } ] }' # Response { "documentId": "doc_abc123", "externalId": "contract_2024_001", "expiresAt": "2024-02-15T23:59:59Z", "signers": [ { "signerId": "signer_1", "name": "John Doe", "email": "john@example.com", "token": "token_xyz789", "role": "SIGNER", "signingOrder": 1, "signingUrl": "https://app.sajn.se/sign/doc_abc123?token=token_xyz789" }, { "signerId": "signer_2", "name": "Jane Manager", "email": "jane@company.com", "token": "token_abc456", "role": "SIGNER", "signingOrder": 2, "signingUrl": "https://app.sajn.se/sign/doc_abc123?token=token_abc456" } ] } ``` ```javascript // Complete document creation with metadata async function createDocument() { const response = await fetch('https://app.sajn.se/api/v1/documents', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ name: 'Service Agreement - Acme Corp', type: 'SIGNABLE', externalId: 'agreement_2024_001', expiresAt: '2024-02-15T23:59:59Z', documentMeta: { subject: 'Service Agreement for Your Review', message: 'Please review and sign this service agreement.', signingOrder: 'SEQUENTIAL', defaultSignatureType: 'DRAWING', distributionMethod: 'EMAIL', forceReadFullDocument: true, preferredLanguage: 'sv', validFrom: '2024-01-01T00:00:00Z', validTo: '2024-12-31T23:59:59Z', value: '500000' }, signers: [ { name: 'Jane Manager', email: 'jane@company.com', role: 'SIGNER', signingOrder: 1 }, { name: 'John Client', email: 'john@acme.com', role: 'SIGNER', signingOrder: 2 } ], customFields: [ { customInputId: 'project_name', value: 'Digital Transformation' }, { customInputId: 'department', value: 'IT' } ] }) }); return await response.json(); } ```