What is Message Level Encryption?
Message Level Encryption (MLE) provides end-to-end encryption for sensitive data transmitted between your application and Method’s API. Using a hybrid encryption approach, MLE ensures your data remains protected even if network traffic is intercepted. MLE uses two layers of encryption:- Symmetric encryption (AES-GCM) encrypts your actual data payload using a Content Encryption Key (CEK)
- Asymmetric encryption (RSA-OAEP-256) encrypts the CEK using Method’s public key
Prerequisites
To use MLE with Method’s API, you’ll need:- An RSA key pair for RSA-OAEP-256
- Ability to create and parse JWE (JSON Web Encryption) in compact serialization format
- Header:
Method-MLE: jwe
- Content-Type:
application/json
- Request body:
{"encrypted": "<compact dot separated JWE string>"}
Setup Guide
Step 1: Generate Your RSA Key Pair
Generate an RSA key pair that will be used to receive encrypted responses from Method.Step 2: Register Your Public Key with Method
You can register your public key using either a well-known endpoint (recommended) or direct registration.Important: Each key ID (
kid
) can only be registered once using either method. If you have a public key available through your well-known endpoint, you should not register the same public key through direct registration, even if you change the kid
.Option A: Well-Known Endpoint (Recommended)
Host your public JWK at a well-known URL and register it with Method:Requirements for keys on .well-known
end-point
- Must have a top-level field named
keys
that has a list as its value. - For a JWK (an item in list of
keys
) to be valid the following must be met:- JWK must be an object
- JWK must have a field named
kty
and it must be equal toRSA
- JWK must have a field
n
and it must be a string that is validn
for a JWK in accordance to the RFC - JWK must have a field
e
and it must be a string that is valide
for a JWK in accordance to the RFC - JWK can optionally have a field named
alg
but if it is provided the value must beRSA-OAEP-256
- JWK must have a field
kid
and it must be a string that is a validid
which will be passed ascid
when making requests to Method
Option B: Direct Registration
Alternatively, register your public key directly:Step 3: Retrieve Method’s Public Key
Fetch Method’s public key for encrypting your requests:Method’s public keys are environment-specific:
- Production:
https://production.methodfi.com/.well-known/jwks.json
- Sandbox:
https://sandbox.methodfi.com/.well-known/jwks.json
- Development:
https://dev.methodfi.com/.well-known/jwks.json
Making Encrypted Requests
Step 1: Encrypt Your Request Payload
Step 2: Send the Encrypted Request
Step 3: Decrypt the Response
Complete Example
Here’s a complete example showing the full MLE flow:Error Handling
When using MLE, you may encounter these specific error codes:Error Type Code | Error Subtype Code | HTTP Status | Description |
---|---|---|---|
api_error | MLE_DECRYPTION_FAILED | 500 | Message level encryption (MLE) requests are temporarily unavailable. To ensure MLE try your request later, or fall back to a non-MLE request. |
api_error | MLE_ENCRYPTION_FAILED | 500 | Message level encryption (MLE) requests are temporarily unavailable. To ensure MLE try your request later, or fall back to a non-MLE request. |
api_error | PAYLOAD_INVALID_JSON | 400 | The request body is not valid JSON. |
invalid_request | MLE_INVALID_HEADER | 400 | When using message level encryption the header ‘Method-MLE’ must be set to ‘jwe’. |
invalid_request | MLE_MISSING_ENCRYPTED_PAYLOAD | 400 | When using message level encryption the payload must contain field ‘encrypted’ |
invalid_request | MLE_UNSUPPORTED_KEY_MANAGEMENT_ALGORITHM | 400 | Key management algorithm provided is not supported. Must use ‘RSA-OAEP-256’ |
invalid_request | MLE_INVALID_ENCRYPTION_ALGORITHM | 400 | Unsupported or missing “enc” in protected header. Expected one of: ‘A256GCM’ or ‘A128GCM’. |
invalid_request | MLE_MUST_INCLUDE_KID | 400 | Must include ‘KID’ in protected header. |
invalid_request | MLE_MUST_INCLUDE_CID | 400 | Must include ‘CID’ in protected header. |
invalid_request | MLE_INVALID_KID | 400 | The JWK KID is either disabled or does not exist. |
invalid_request | MLE_INVALID_CID | 400 | The JWK CID is either disabled or does not exist. |
invalid_request | MLE_INVALID_JWE_FORMAT | 400 | The MLE “encrypted” payload must be in the RFC compatible compact format. |
invalid_request | WELL_KNOWN_ENDPOINT_ALREADY_EXISTS | 400 | An active well-known endpoint already exist. Must delete already existing well-known endpoint to post a new one. |
invalid_request | JWK_KID_ALREADY_EXISTS | 400 | The specified JWK KID already exists. |
invalid_request | JWK_ALREADY_DISABLED | 400 | The specified JWK is already disabled. |
invalid_request | JWK_ALREADY_EXISTS | 400 | The specified JWK’s public content matches another key you have posted. Based on thumbprint from n , e , kty . |
Performance Considerations
- MLE requests have increased latency due to encryption/decryption operations
- Consider implementing request timeouts appropriately
- Cache Method’s public keys (respect the
Cache-Control
header)
Key Lifecycle and Management
Method’s Key Status
Method’s public keys have two possible statuses:- Active: Current keys that should be used for encryption
- Deprecated: Keys that are being phased out and will be disabled in 90 days
status: "active"
when fetching Method’s public keys. Deprecated keys remain functional for 90 days before being completely disabled.
Your Key Management
When you successfully register a key with Method, you’ll receive a response like this:MLE Public Keys API
For complete CRUD operations on your MLE public keys, see the dedicated API documentation:- Create MLE Public Key - Register a new public key
- List MLE Public Keys - Get all your registered keys
- Retrieve MLE Public Key - Get a specific key by ID
- Delete MLE Public Key - Delete (disable) a specific key
Quick Key Deletion Example
You can delete your registered keys using theid
returned when you created the key:
Key Rotation Best Practices
- Method recommends rotating your keys every 90 days
- Always check for keys with
status: "active"
when fetching Method’s keys - Plan your key rotation to avoid service interruptions
Webhook Notifications
You can subscribe to webhook events to be notified when Method’s public keys change:Event Type | Description |
---|---|
method_jwk.create | Triggered when a new Method JWK (public key) is created |
method_jwk.update | Triggered when a Method JWK is updated (deprecated or disabled) |
- Automatically fetch new active keys when they’re created
- Update your cached keys when Method rotates or deprecates keys
- Implement proactive key management in your application
path
field pointing to the specific key that changed. You can use this path to retrieve the updated key information via the Retrieve Method Public Key endpoint.
Example webhook event:
Fallback Strategy
If MLE is temporarily unavailable (indicated byMLE_DECRYPTION_FAILED
or MLE_ENCRYPTION_FAILED
errors), you can fall back to standard non-encrypted requests by:
- Remove the
Method-MLE: jwe
header - Send your payload directly (not wrapped in
encrypted
) - Process the plain response normally