@@ -482,52 +482,135 @@ json
482482
483483---
484484
485- ## 🔹 3 Redirect URL
485+ Got it — here’s the ** corrected Markdown section ** based on your actual API and response. You can directly append this to your doc:
486486
487- The ** Redirect URL API** is used to define or retrieve the URL where users are redirected after completing specific actions such as login, email verification, or E-Sign processes.
487+ ---
488+
489+ ## 🔹 5 Redirect URL (PDF Editor)
490+
491+ The ** Redirect URL API** is used to securely generate a session for accessing the third-party PDF editor.
492+ This API uses ** API Key authentication only (no login required)** and returns a scoped bearer token along with the editor UI URL.
493+
494+ ---
488495
489496### ** Endpoint**
490497
491498```
499+
492500POST /api/v1/documents/auth/redirect
501+
493502```
494503
495- <!-- ### **Headers**
496- | Name | Type | Required | Description |
497- | ------------------- | ------------------ | -------- | ---------------------------------------------------------- |
498- | `x-api-key` | string | ✅ Yes | API key used to authenticate the request |
499- | `Content type` | application/json | ✅ Yes | Specifies that the API response is returned in JSON format |
504+ ---
505+ <!--
506+ ### **Headers**
500507
501- ### **Query Parameters**
502- > _None_
508+ | Name | Type | Required | Description |
509+ |-------------|--------|----------|--------------------------------------|
510+ | X-API-Key | string | ✅ Yes | API key for client authentication |
511+ | accept | string | ✅ Yes | application/json |
512+
513+ --- -->
503514
504515### ** Request Body**
505- > _Not required_ -->
516+ > _ Not required_
517+
518+ ---
506519
507520### ** Response Body Example**
508521
509522```
523+
510524json
511525
512526{
513- "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.samplePayload.signaturePart123456789",
514- "ui_url": "https://dev.example.com/pdf-editor",
515- "token_type": "Bearer",
527+ "client_id": "client_xxxxxxxxxxx1bb23c0a105316",
528+ "email": "sample@example.com",
529+ "role": "admin",
530+ "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.samplePayload.signature",
531+ "ui_url": "https://demo.doculandemo.com/pdf-editor",
532+ "token_type": "bearer"
516533}
517534
518535```
519- <!-- ### **Responses**
520536
521- | Status Code | Description |
522- | ------------------------------------------------------- | ------------------- |
523- | <span style="color:green; font-weight:bold;">200</span> | Successful response |
524- | <span style="color:green; font-weight:bold;">201</span> | Created |
525- | <span style="color:green; font-weight:bold;">202</span> | Accepted |
526- | <span style="color:red; font-weight:bold;">404</span> | Not Found |
527- | <span style="color:red; font-weight:bold;">422</span> | Validation error |
528- | <span style="color:red; font-weight:bold;">500</span> | Internal Server Error | -->
537+ ---
529538
530- ### Tags
539+ ### ** Response Fields**
540+
541+ | Field | Type | Description |
542+ | ---------------| --------| ----------------------------------------------------------|
543+ | client_id | string | Unique identifier for the client |
544+ | email | string | Associated client email |
545+ | role | string | Role assigned to the client (e.g., admin) |
546+ | access_token | string | Bearer token used for authentication in editor session |
547+ | ui_url | string | Third-party PDF editor URL |
548+ | token_type | string | Token type (always ` bearer ` ) |
549+
550+ ---
551+
552+ ### ** Usage Flow**
553+
554+ 1 . Call the API using your ** X-API-Key**
555+ 2 . Receive:
556+ - ` access_token `
557+ - ` ui_url `
558+ 3 . Load ` ui_url ` inside an iframe or browser
559+ 4 . Pass the following data to the editor via ` postMessage `
560+
561+ ---
562+
563+ ### ** PostMessage Payload**
564+
565+ ```
566+
567+ json
568+
569+ {
570+ "type": "INIT_DATA",
571+ "payload": {
572+ "document_id": "string",
573+ "access_token": "string"
574+ }
575+ }
576+
577+ ```
578+
579+ ---
580+
581+ ### ** Important Notes**
582+
583+ - No user login is required — authentication is handled via API Key
584+ - The ` access_token ` is ** short-lived and scoped to the client**
585+ - Ensure secure communication by restricting ` postMessage ` origin in production
586+
587+ Example:
588+
589+ ```
590+
591+ postMessage(data, "https://demo.doculandemo.com");
592+
593+ ```
594+
595+ ---
596+
597+ ### ** Error Handling**
598+
599+ - If the API call fails, retry with a valid API key
600+ - Ensure the iframe is fully loaded before sending data
601+ - Handle cases where ` access_token ` is not yet available
602+
603+ ---
604+
605+ ### ** Required Parameters**
606+
607+ | Parameter | Required | Description |
608+ | --------------| ----------| ----------------------------|
609+ | document_id | ✅ Yes | Document to be edited |
610+ | access_token | ✅ Yes | Bearer token for authenticating the session |
611+ ---
612+
613+ ### Tags
531614` Files Operation `
532615
533616---
0 commit comments