# Get Public Key

> Retrieve the RSA public key for encrypting sensitive merchant application data. **Content-Type**: `application/json` **Authentication**: None required (public endpoint) **Response**: Returns base64-encoded RSA public key for client-side encryption

Source: https://help.boltapp.com/api-reference/merchant-onboarding/merchant-applications/get-public-key

`GET /v1/merchant-application/public-key`

## OpenAPI definition

This endpoint as it appears in the OpenAPI document, with every schema it references included.

```json
{
  "openapi": "3.2.0",
  "info": {
    "title": "Bolt Connect Merchant Onboarding API",
    "version": "1.0.0",
    "description": "## Overview\nThis collection provides comprehensive access to Bolt's Platform Connected Merchant Onboarding APIs, designed to enable platform platforms to onboard their sub-merchants seamlessly. The APIs support two primary workflows:\n1. **Direct Onboarding**: Platforms can directly onboard sub-merchants using the merchant application APIs\n2. **Self-Onboarding**: Platforms can generate sharable links for sub-merchants to complete their own onboarding\n\n## API Workflow\nThe typical onboarding workflow follows these steps:\n1.  **Get Public Key** (`GET /v1/merchant-application/public-key`):<br>\nRetrieve RSA public key for encrypting \nsensitive data\n2. **Create Application** (`POST /v1/merchant_applications`):<br>\nCreate a new merchant application with encrypted company information\n3. **Upload Attachments** (`POST /v1/merchant_applications/{id}/attachments`): Upload required documents (tax verification, bank statements, etc.)\n4. **Update Application** (`PUT /v1/merchant_applications/{id}`):<br>\nComplete the application with encrypted form submission\n5. **Generate Link** (Optional) (`POST /v1/merchant_applications/onboarding_link`):\nGenerate self-onboarding link for sub-merchants\n\n## Encryption\n Sensitive data in requests uses hybrid encryption with the RSA-4096 public key from the public key endpoint:\n 1. Wrap your JSON payload as a string in an envelope with a Unix timestamp in seconds: `{\"data\": \"<payload as a JSON string>\", \"timestamp\": 1730000000}`. Bolt rejects timestamps more than 5 minutes old.\n 2. Encrypt the envelope with AES-256-GCM using a random 32-byte key and a random 12-byte IV.\n 3. Encrypt the AES key with RSA-OAEP (SHA-256) using the public key.\n 4. Send `encrypted_data` (base64 of IV + RSA-encrypted key + AES ciphertext and tag), `nonce` (base64 of 32 random bytes, new for every request) and `public_key` (the base64 value from the public key endpoint).\n\n ### Node.js encryption example\n ```javascript\n const crypto = require('crypto');\n const axios = require('axios');\n\n async function encryptPayload(baseUrl, jsonPayload) {\n   // Fetch the base64-encoded PEM public key\n   const { data } = await axios.get(`${baseUrl}/v1/merchant-application/public-key`);\n   const publicKeyBase64 = data.public_key;\n   const publicKeyPEM = Buffer.from(publicKeyBase64, 'base64').toString('utf8');\n\n   // Envelope: the payload as a JSON string plus a Unix timestamp in seconds\n   const envelope = JSON.stringify({\n     data: JSON.stringify(jsonPayload),\n     timestamp: Math.floor(Date.now() / 1000),\n   });\n\n   // AES-256-GCM for the envelope\n   const aesKey = crypto.randomBytes(32);\n   const iv = crypto.randomBytes(12);\n   const cipher = crypto.createCipheriv('aes-256-gcm', aesKey, iv);\n   const ciphertext = Buffer.concat([\n     cipher.update(envelope, 'utf8'),\n     cipher.final(),\n     cipher.getAuthTag(),\n   ]);\n\n   // RSA-OAEP with SHA-256 for the AES key (512 bytes with RSA-4096)\n   const encryptedKey = crypto.publicEncrypt(\n     { key: publicKeyPEM, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, oaepHash: 'sha256' },\n     aesKey,\n   );\n\n   return {\n     encrypted_data: Buffer.concat([iv, encryptedKey, ciphertext]).toString('base64'),\n     nonce: crypto.randomBytes(32).toString('base64'),\n     public_key: publicKeyBase64,\n   };\n }\n\n // Example usage\n const baseUrl = 'https://api.boltapp.com';\n const payload = {\n   company_information: {\n     email_address: 'company@example.com',\n     phone_number: '+1234567890',\n     registered_address: {\n       address_line1: '123 Main St',\n       city: 'San Francisco',\n       state: 'CA',\n       zip: '94105',\n       country: 'US',\n     },\n     billing_address: {\n       address_line1: '123 Main St',\n       city: 'San Francisco',\n       state: 'CA',\n       zip: '94105',\n       country: 'US',\n     },\n     annual_processing_volume: 1000000,\n     average_transaction_value: 5000,\n     highest_transaction_value: 10000,\n   },\n };\n\n encryptPayload(baseUrl, payload)\n   .then((body) =>\n     axios.post(`${baseUrl}/v1/merchant_applications`, body, {\n       headers: { 'Content-Type': 'application/json', 'X-API-Key': 'your-api-key' },\n     }),\n   )\n   .then((response) => console.log('Merchant application created:', response.data))\n   .catch((error) => console.error('Request failed:', error));\n ```\n"
  },
  "servers": [
    {
      "url": "https://api.boltapp.com"
    }
  ],
  "paths": {
    "/v1/merchant-application/public-key": {
      "get": {
        "operationId": "get_public_key",
        "summary": "Get Public Key",
        "description": "Retrieve the RSA public key for encrypting sensitive merchant application data.\n\n**Content-Type**: `application/json`\n\n**Authentication**: None required (public endpoint)\n\n**Response**: Returns base64-encoded RSA public key for client-side encryption",
        "responses": {
          "200": {
            "description": "RSA public key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "public_key": {
                      "type": "string",
                      "description": "Base64-encoded PEM RSA public key"
                    }
                  },
                  "required": [
                    "public_key"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "public_key": "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUF4..."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "Internal Server Error": {
                    "value": {
                      "errors": [
                        {
                          "code": 46,
                          "message": "Internal error",
                          "field": ""
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Merchant Applications"
        ],
        "security": []
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "integer",
                  "description": "Numeric error code"
                },
                "message": {
                  "type": "string",
                  "description": "Human-readable error message"
                },
                "field": {
                  "type": "string",
                  "description": "Field related to the error, if applicable"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "API key used to authorize requests for non-public endpoints."
      }
    }
  }
}
```
