### Install Soyio SDKs via npm Source: https://docs.soyio.id/docs/integration-guide/disclosure/quickstart Installs the Soyio web widget and React Native SDK using npm. Requires Node.js and internet access. Run the commands in your project directory. ```bash npm install @soyio/soyio-widget ``` ```bash npm install @soyio/soyio-rn-sdk ``` -------------------------------- ### Get All Entities API Request Examples Source: https://docs.soyio.id/docs/api/resources/index-entities Examples of how to call the 'Get All Entities' endpoint using various programming languages and tools. These examples demonstrate making a GET request to the API with necessary headers and parameters. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/entities") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` ```curl curl -X GET \ 'https://sandbox.soyio.id/api/v1/entities?page=1&per_page=20&where=%7B%22user_reference%22%3A%7B%22%3D%22%3A%22user_123%22%7D%7D&order_by=created_at%20DESC' \ -H 'Accept: application/json' \ -H 'Authorization: ' ``` ```php " ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Curl error: ' . curl_error($ch); } c_close($ch); echo $response; ?> ``` ```python import requests url = "https://sandbox.soyio.id/api/v1/entities" headers = { "Accept": "application/json", "Authorization": "" } params = { "page": 1, "per_page": 20, "where": {"user_reference": {"=": "user_123"}}, "order_by": "created_at DESC" } response = requests.get(url, headers=headers, params=params) print(response.json()) ``` ```java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class GetEntities { public static void main(String[] args) throws IOException, InterruptedException { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://sandbox.soyio.id/api/v1/entities?page=1&per_page=20&where=%7B%22user_reference%22%3A%7B%22%3D%22%3A%22user_123%22%7D%7D&order_by=created_at%20DESC")) .header("Accept", "application/json") .header("Authorization", "") .GET() .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class ApiClient { public static async Task GetEntitiesAsync() { using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("Authorization", ""); string url = "https://sandbox.soyio.id/api/v1/entities?page=1&per_page=20&where=%7B%22user_reference%22%3A%7B%22%3D%22%3A%22user_123%22%7D%7D&order_by=created_at%20DESC"; HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } } ``` ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { url := "https://sandbox.soyio.id/api/v1/entities?page=1&per_page=20&where=%7B%22user_reference%22%3A%7B%22%3D%22%3A%22user_123%22%7D%7D&order_by=created_at%20DESC" client := &http.Client{} req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println(err) return } req.Header.Add("Accept", "application/json") req.Header.Add("Authorization", "") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` ```powershell $url = "https://sandbox.soyio.id/api/v1/entities?page=1&per_page=20&where=%7B%22user_reference%22%3A%7B%22%3D%22%3A%22user_123%22%7D%7D&order_by=created_at%20DESC" $headers = @{ "Accept" = "application/json" "Authorization" = "" } Invoke-RestMethod -Uri $url -Method Get -Headers $headers ``` -------------------------------- ### Initialize Soyio Widget on Frontend (JavaScript) Source: https://docs.soyio.id/docs/integration-guide/disclosure/quickstart Imports SoyioWidget, configures it with the disclosure request ID, and handles widget events such as success and closure. Works in web applications after installing the @soyio/soyio-widget package. ```javascript import { SoyioWidget } from \"@soyio/soyio-widget\";\nconst widgetConfig = {\n request: \"disclosure\",\n configProps: {\n disclosureRequestId: disclosure_request_id\n },\n onEvent: (event) => {\n switch(event.type) {\n case 'DISCLOSURE_REQUEST_SUCCESSFUL':\n console.log('¡Proceso completado!');\n break;\n case 'WIDGET_CLOSED':\n console.log('Widget cerrado');\n break;\n }\n }\n};\nnew SoyioWidget(widgetConfig); ``` -------------------------------- ### Retrieve API Keys using various programming languages Source: https://docs.soyio.id/docs/api/resources/index-api-keys Examples demonstrating how to fetch API keys using the specified endpoint in different programming languages. Each example includes the necessary HTTP request setup, headers, and response handling. Ensure you replace '' with your actual API key. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/api_keys") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` ```nodejs const https = require('https'); const options = { hostname: 'sandbox.soyio.id', port: 443, path: '/api/v1/api_keys', method: 'GET', headers: { 'Accept': 'application/json', 'Authorization': '' } }; const req = https.request(options, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { console.log(JSON.parse(data)); }); }); req.on('error', (error) => { console.error(error); }); req.end(); ``` ```python import requests url = "https://sandbox.soyio.id/api/v1/api_keys" headers = { "Accept": "application/json", "Authorization": "" } response = requests.get(url, headers=headers) print(response.json()) ``` ```curl curl -X GET \ 'https://sandbox.soyio.id/api/v1/api_keys' \ -H 'Accept: application/json' \ -H 'Authorization: ' ``` ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class ApiKeyFetcher { public static async Task GetApiKeysAsync() { var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://sandbox.soyio.id/api/v1/api_keys") }; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", ""); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } } ``` ```java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class ApiKeyFetcher { public static void main(String[] args) throws IOException, InterruptedException { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://sandbox.soyio.id/api/v1/api_keys")) .header("Accept", "application/json") .header("Authorization", "") .GET() .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` ```php " ]; curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($curl); if (curl_errno($curl)) { echo 'Error:' . curl_error($curl); } custom_close($curl); echo $response; ?> ``` ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { url := "https://sandbox.soyio.id/api/v1/api_keys" client := &http.Client{} req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Add("Accept", "application/json") req.Header.Add("Authorization", "") resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println(string(body)) } ``` ```powershell Invoke-RestMethod -Uri "https://sandbox.soyio.id/api/v1/api_keys" -Method Get -Headers @{ "Accept" = "application/json" "Authorization" = "" } ``` -------------------------------- ### Get Webhook - Go Source: https://docs.soyio.id/docs/api/resources/get-webhook This example shows how to retrieve a webhook in Go using the `net/http` package. The API key is passed in the Authorization header. This code example demonstrates sending an HTTP GET request. ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { req, err := http.NewRequest("GET", "https://sandbox.soyio.id/api/v1/webhooks/:id", nil) if err != nil { fmt.Println(err) return } req.Header.Add("Accept", "application/json") req.Header.Add("Authorization", "") resp, err := http.DefaultClient.Do(req) if err != nil { fmt.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Create Disclosure Request Source: https://docs.soyio.id/docs/integration-guide/disclosure/quickstart This endpoint allows you to create a disclosure request from your backend. You need a pre-existing disclosure template and valid API credentials. ```APIDOC ## POST /api/v1/disclosure_requests ### Description Creates a disclosure request to initiate the data disclosure and consent process with a user. ### Method POST ### Endpoint https://sandbox.soyio.id/api/v1/disclosure_requests ### Parameters #### Query Parameters None #### Request Body - **disclosure_template_id** (string) - Required - The ID of the disclosure template to use. - **user_reference** (string) - Required - A unique reference identifier for the user. - **user_email** (string) - Required - The email address of the user. ### Request Example ```json { "disclosure_template_id": "dtpl_...", "user_reference": "user_123", "user_email": "user@example.com" } ``` ### Response #### Success Response (200) - **disclosure_request_id** (string) - The ID of the created disclosure request. #### Response Example ```json { "disclosure_request_id": "dr_..." } ``` ``` -------------------------------- ### API Key Authentication Example (Ruby) Source: https://docs.soyio.id/docs/api/resources/index-disclosure-templates Demonstrates how to authenticate requests to the Soyio.id API using an API key provided in the 'Authorization' header. This example uses Ruby's Net::HTTP library to make a GET request. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/disclosure_templates") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` -------------------------------- ### Create Disclosure Request from Backend (JavaScript) Source: https://docs.soyio.id/docs/integration-guide/disclosure/quickstart Uses fetch to POST a disclosure request to the Soyio sandbox API. Requires an API key and a disclosure template ID. Returns a disclosure_request_id for further processing. ```javascript const response = await fetch('https://sandbox.soyio.id/api/v1/disclosure_requests', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': 'YOUR_API_KEY'\n },\n body: JSON.stringify({\n disclosure_template_id: \"dtpl_...\",\n user_reference: \"user_123\",\n user_email: \"user@example.com\"\n })\n});\nconst { disclosure_request_id } = await response.json(); ``` -------------------------------- ### Initialize Web Authentication Flow with Soy.io Widget Source: https://docs.soyio.id/docs/integration-guide/authentication/authenticate-users This snippet demonstrates how to initialize the authentication flow using the Soy.io Web SDK. It includes setting up the widget configuration, creating the widget instance, and attaching an event listener to a button to trigger the authentication process. Dependencies include the '@soyio/soyio-widget' package. ```html ``` ```javascript import { SoyioWidget } from "@soyio/soyio-widget"; // Configuración const widgetConfig = { request: "authentication", configProps: { authRequestId: "", customColor: "" }, onEvent: (data) => console.log(data) }; // Creación del widget function initWidget() { new SoyioWidget(widgetConfig); } // Añade un escuchador de eventos al botón para inicializar el widget al hacer clic document .getElementById("start-auth-request") .addEventListener("click", initWidget); ``` -------------------------------- ### Fetch Product Versions with Ruby (NET::HTTP) Source: https://docs.soyio.id/docs/api/resources/index-product-versions This Ruby code snippet demonstrates how to fetch all versions of a product using the NET::HTTP library. It constructs the request URL, sets necessary headers like 'Accept' and 'Authorization', and sends a GET request to the API. ```Ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/products/:id/versions") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` -------------------------------- ### Get Webhook - PHP Source: https://docs.soyio.id/docs/api/resources/get-webhook This example demonstrates fetching a webhook in PHP using the cURL library. The API key is included in the Authorization header. This shows a practical example of making an HTTP GET request. ```php "); $response = file_get_contents($url, false, stream_context_create(['http' => ['header' => $headers]])); if ($response) { echo $response; } else { echo "Request failed"; } ?> ``` -------------------------------- ### Get Webhook - Node.js Source: https://docs.soyio.id/docs/api/resources/get-webhook Example demonstrating retrieval of a webhook using Node.js. The API key is provided within the Authorization header. This code shows how to formulate and send a GET request. ```nodejs const https = require('https'); const url = 'https://sandbox.soyio.id/api/v1/webhooks/:id'; https.get(url, (resp) => { let data = ''; resp.on('data', (chunk) => { data += chunk; }); resp.on('end', () => { console.log(data); }); }).on('error', (err) => { console.error('Error:', err); }); ``` -------------------------------- ### Get Webhook - C# Source: https://docs.soyio.id/docs/api/resources/get-webhook Demonstrates how to retrieve a webhook using C# and the HttpClient class. The Authorization header includes the API key. This example showcases sending an HTTP GET request and handling the response. ```csharp using System.Net.Http; using System.Threading.Tasks; public async Task GetWebhook(string webhookId) { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Add("Accept", "application/json"); client.DefaultRequestHeaders.Add("Authorization", ""); var response = await client.GetAsync("https://sandbox.soyio.id/api/v1/webhooks/" + webhookId); if (response.IsSuccessStatusCode) { return await response.Content.ReadAsStringAsync(); } else { return "Request failed: " + response.StatusCode; } } } ``` -------------------------------- ### Configuración de Entorno: Sandbox vs. Producción Source: https://docs.soyio.id/docs/integration-guide/production Ejemplo de configuración de variables de entorno para las API Keys y URLs base de los entornos de sandbox y producción de Soyio. ```shell # Ambiente sandbox SOYIO_API_KEY=ak_sandbox_1B2M2Y8AsgTpgAmY7PhCfg SOYIO_BASE_URL=https://sandbox.soyio.id # Ambiente production SOYIO_API_KEY=ak_live_2C3N3Z9BthUpgBnZ8QiDgh SOYIO_BASE_URL=https://app.soyio.id ``` -------------------------------- ### Get Webhook - Ruby Source: https://docs.soyio.id/docs/api/resources/get-webhook Example of retrieving a webhook using Ruby and Net::HTTP. Requires an active API key passed in the Authorization header. This shows how to make a GET request to the specified endpoint with the necessary headers. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/webhooks/:id") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` -------------------------------- ### Get Webhook - cURL Source: https://docs.soyio.id/docs/api/resources/get-webhook Example using cURL to fetch a webhook. The API key is provided in the Authorization header. This demonstrates a straightforward command-line request to retrieve the webhook data. ```curl curl -X GET \ "https://sandbox.soyio.id/api/v1/webhooks/:id" \ -H "Accept: application/json" \ -H "Authorization: " ``` -------------------------------- ### Example Consent Template Creation Source: https://docs.soyio.id/docs/api/resources/create-consent-template An example JSON object representing a successfully created basic consent template. It includes all required fields and some optional ones, demonstrating the structure for API integration. ```json { "id": "constpl_wAspvmEr4ACDZaPUtfwjsA", "name": "Consentimiento básico", "version": 1, "duration": "P12M3H", "title": "Consentimiento general", "text": "De acuerdo a los {{ terms_and_conditions }} y {{ privacy_policy }} de Soyio.", "data_requirements": [ { "key": "first_name", "data_category": "user.name.first", "data_uses": [ "string" ] } ], "data_subject": "customer", "product_id": "prod_1B2M2Y8AsgTpgAmY7PhCfg", "branch_id": "branch_1B2M2Y8AsgTpgAmY7PhCfg", "optional": false, "enabled": true, "created_at": "2024-03-20T15:30:00Z", "updated_at": "2024-03-21T10:15:00Z", "event_logs": [ { "timestamp": "2024-03-20T15:30:00Z", "type": "created", "description": "Consent template created", "payload": { "version": 1, "created_by": "cusr_123" } } ] } ``` -------------------------------- ### Retrieve Entity Compliance Statuses - Ruby Example Source: https://docs.soyio.id/docs/api/resources/get-entity-agreement-compliance-statuses Example of how to fetch entity compliance statuses using Ruby's Net::HTTP library. It demonstrates making a GET request to the API endpoint with necessary headers. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/entities/:id/agreement/compliance_statuses") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` -------------------------------- ### Iniciar Proceso de Firma (Frontend Widget) Source: https://docs.soyio.id/docs/integration-guide/signature/sign-documents Utiliza el SDK Web de Soyio para iniciar el widget de firma en el frontend. Se requiere el ID del intento de firma obtenido previamente. El widget maneja la previsualización, firma y eventos del flujo. ```javascript ``` -------------------------------- ### Fetch Product Version using Ruby (NET::HTTP) Source: https://docs.soyio.id/docs/api/resources/get-product Demonstrates how to make a GET request to the SoyIO API to fetch a specific product's version using Ruby's NET::HTTP library. It includes setting headers for authentication and content type. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/products/:id") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` -------------------------------- ### API Key Authentication Example (Ruby) Source: https://docs.soyio.id/docs/api/resources/index-consent-commits Demonstrates how to authenticate requests to the SoyIO API using an API key provided in the 'Authorization' header. This example uses Ruby's Net::HTTP library to make a GET request. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/consent_commits") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` -------------------------------- ### Initiate Signing Widget Source: https://docs.soyio.id/docs/integration-guide/signature/sign-documents Launches the Soyio signing widget in the frontend using the `signature_attempt_id` obtained from the 'Create Signature Attempt' step. This allows the user to preview, sign, and complete the document. ```APIDOC ## Initialize Soyio Widget ### Description Initializes the Soyio Widget in the user's browser to start the document signing process. This requires the `signature_attempt_id` obtained from the POST /api/v1/signature_attempts endpoint. ### Method JavaScript (Client-side) ### Endpoint N/A (Client-side integration) ### Parameters #### Configuration Object (JavaScript) - **request** (string) - Required - Must be set to "signature". - **configProps** (object) - Required - Contains properties for the widget configuration. - **signatureAttemptId** (string) - Required - The ID of the signature attempt generated by the API. - **onEvent** (function) - Optional - A callback function to handle events emitted by the widget (e.g., WIDGET_OPENED, IDENTITY_SIGNATURE). ### Request Example ```javascript ``` ### Response #### Success Response The Soyio Widget UI is displayed to the user. Events are logged via the `onEvent` callback. #### Response Example (Event Data) ```json // Example event data when the widget opens { "type": "WIDGET_OPENED" } // Example event data when the user successfully signs { "type": "IDENTITY_SIGNATURE", "payload": { "signatureAttemptId": "sa_..." } } ``` ``` -------------------------------- ### Get Specific Event Details (API Request Examples) Source: https://docs.soyio.id/docs/api/resources/get-event This snippet demonstrates how to fetch details for a specific event using its ID via the Soyio.id API. It requires an 'Authorization' header for authentication and expects a JSON response. The API supports multiple programming languages for integration. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/events/:id") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` ```nodejs // Node.js example would go here, similar to other languages ``` ```python # Python example would go here, similar to other languages ``` ```curl # cURL example would go here, similar to other languages ``` ```csharp // C# example would go here, similar to other languages ``` ```java // Java example would go here, similar to other languages ``` ```php // PHP example would go here, similar to other languages ``` ```go // Go example would go here, similar to other languages ``` ```powershell # PowerShell example would go here, similar to other languages ``` -------------------------------- ### Agreement Response Example (JSON) Source: https://docs.soyio.id/docs/api/resources/get-agreement-versions This snippet presents an example of the 'agreements' response format. It includes a list of agreement objects, each with details like ID, version, subject information, data permissions, user reference, and creation timestamp. This structure supports displaying and managing agreements within the Soy.io platform. ```json { "agreements": [ { "id": "agr_IdBeyWCa1ENLUYnPRLpCUg", "version": 1, "subject_id": "ent_ma21KLsmaslopask912Aa2", "subject_type": "Entity", "version_source_type": "ConsentCommit", "version_source_id": "consact_1B2M2Y8AsgTpgAmY7PhCfg", "data_permissions": [ { "data_category": "user.name.first", "data_label": "name", "data_use": "essential.service.authentication", "scope_type": "product", "scope_id": "string", "scope_version": "string", "expires_at": "2024-07-29" } ], "user_reference": "user_123", "previous_evidence_ids": [ "evd_pNMroI2OEfrDNdi8xT6kOQ" ], "created_at": "2024-11-21T14:54:57.167Z" } ], "metadata": { "page": 1, "per_page": 20, "total": 45, "order_by": "created_at DESC", "filters": { "status": { "=": "pending" } } } } ``` -------------------------------- ### POST /api/v1/consent_templates Source: https://docs.soyio.id/docs/integration-guide/consent/quickstart Creates a consent template that defines what data and purposes you will request consent for. This example creates a marketing communications consent template with a 12-month duration. ```APIDOC ## POST /api/v1/consent_templates ### Description Creates a consent template that defines data categories and uses for which consent will be requested. This endpoint is used to establish the legal basis for data processing activities. ### Method POST ### Endpoint /api/v1/consent_templates ### Parameters #### Request Body - **name** (string) - Required - Internal name for the consent template - **duration** (string) - Required - ISO 8601 duration format for consent validity (e.g., P12M for 12 months) - **title** (string) - Required - Title displayed in the consent checkbox - **text** (string) - Required - Detailed consent clause displayed in the checkbox - **data_requirements** (array) - Required - List of data categories and their permitted uses ### Request Example { "name": "Template de consentimiento para Comunicaciones Comerciales", "duration": "P12M", "title": "Comunicaciones Comerciales", "text": "Autorizo el uso de mis datos personales para el envío de comunicaciones comerciales relacionadas con productos y servicios de la empresa.", "data_requirements": [ { "data_category": "name", "data_uses": [ "marketing", "marketing.communications.email", "marketing.advertising" ] }, { "data_category": "email", "data_uses": [ "marketing", "marketing.communications.email", "marketing.advertising" ] } ] } ### Response #### Success Response (200) - **id** (string) - Unique identifier for the created consent template - **name** (string) - Template name - **duration** (string) - Consent duration in ISO 8601 format - **title** (string) - Display title - **text** (string) - Consent text - **data_requirements** (array) - Data requirements configuration #### Response Example { "id": "constpl_1234567890", "name": "Template de consentimiento para Comunicaciones Comerciales", "duration": "P12M", "title": "Comunicaciones Comerciales", "text": "Autorizo el uso de mis datos personales para el envío de comunicaciones comerciales relacionadas con productos y servicios de la empresa.", "data_requirements": [ { "data_category": "name", "data_uses": [ "marketing", "marketing.communications.email", "marketing.advertising" ] }, { "data_category": "email", "data_uses": [ "marketing", "marketing.communications.email", "marketing.advertising" ] } ] } ``` -------------------------------- ### POST /api/v1/consent_actions Source: https://docs.soyio.id/docs/integration-guide/consent/quickstart Creates a consent record using an action token obtained from the consent capture process. Optionally associates the consent with a user reference for future tracking. ```APIDOC ## POST /api/v1/consent_actions ### Description Creates a consent record using an action token obtained from the consent capture process. This endpoint should be called after obtaining an action token and before using user data. Optionally associates the consent with a user reference. ### Method POST ### Endpoint /api/v1/consent_actions ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **action_token** (string) - Required - Action token obtained from the consent capture step - **user_reference** (string) - Optional - User identifier to associate with the consent record for future references ### Request Example { "action_token": "", "user_reference": "" } ### Response #### Success Response (201) - **action** (object) - Created consent action object - **entity_id** (string) - Unique identifier of the user who granted consent in Soyio, recommended to save this for future references #### Response Example { "action": { "entity_id": "", "action_token": "", "user_reference": "", "created_at": "" } } ``` -------------------------------- ### Retrieve Branch - Ruby Source: https://docs.soyio.id/docs/api/resources/get-branch Ruby example using NET::HTTP to make a GET request to retrieve a specific branch. Requires the branch ID and an API key for authorization. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/branches/:id") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` -------------------------------- ### Product Schema and Example Response Source: https://docs.soyio.id/docs/api/resources/get-product Defines the structure of the product object returned by the API, including fields like id, name, branch_id, version, and created_at. An example JSON response is provided. ```json { "product": { "id": "product_1B2M2Y8AsgTpgAmY7PhCfg", "name": "Mi Producto", "branch_id": "branch_1B2M2Y8AsgTpgAmY7PhCfg", "version": 1, "created_at": "2024-03-20T15:30:00Z" } } ``` -------------------------------- ### Authenticate API Request with API Key (Ruby) Source: https://docs.soyio.id/docs/api/resources/get-agreement-evidences Demonstrates how to authenticate an API request using an API key provided in the header. This example uses the Net::HTTP library in Ruby to make a GET request to the Soyio API. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/agreements/:id/evidences") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` -------------------------------- ### Create Product API Integration Source: https://docs.soyio.id/docs/api/resources/create-product Complete implementation for creating products through the SoyIO API using HTTP POST requests. Includes authentication via API key in Authorization header, JSON request body with product name and branch ID, and handles both success and error responses ```ruby require "uri" require "json" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/products") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = "application/json" request["Accept"] = "application/json" request["Authorization"] = "" request.body = JSON.dump({ "name": "Mi Producto", "branch_id": "branch_1B2M2Y8AsgTpgAmY7PhCfgg" }) response = https.request(request) puts response.read_body ``` -------------------------------- ### Make authenticated API request in Ruby Source: https://docs.soyio.id/docs/api/resources/get-agreement-version This Ruby example demonstrates how to make a GET request to the Soyio API with an Authorization header. It uses the NET::HTTP library for the HTTP request and requires the URI module for URL handling. ```ruby require "uri" require "net/http" url = URI("https://sandbox.soyio.id/api/v1/agreements/:id/versions/:versionNumber") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Authorization"] = "" response = https.request(request) puts response.read_body ``` -------------------------------- ### Evidence JSON Schema Example Source: https://docs.soyio.id/docs/api/resources/get-agreement-evidences Example JSON response showing a complete evidence record with consent details, actions, and metadata. Demonstrates the structure for API responses when retrieving evidence records. ```JSON { "evidences": [ { "id": "evd_wCntp5aXB5q7fKSthevwrw", "integrity_hash": "28b0f934...", "legal_basis": "consent", "consent_method": { "channel": "website", "details": "cliked in selector tab to opt-in consent", "capture_facilitator": "Soyio", "capture_source": "Salesforce", "metadata": { "details": "se le mostr\u00f3 al usuario el texto de consentimiento en un chatbot de whatsapp", "chat_id": 13928 }, "actions": [ { "kind": "grant", "action_type": "opt_in_click", "action_data": { "checkbox_id": "cb_123" }, "action_id": "consact_1B2M2Y8AsgTpgAmY7PhCfg", "template_id": "ctmpl_1B2M2Y8AsgTpgAmY7PhCfg", "template_version": 1, "timestamp": "2024-03-20T15:30:00Z", "contextual_data": { "ip": "192.168.1.1", "user_agent": "Mozilla/5.0", "url": "https://example.com", "phone_number": "+56912345678" } } ] } } ] } ```