Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mercadopago/sdk-java/llms.txt
Use this file to discover all available pages before exploring further.
MercadoPagoConfig is the central configuration class for the Mercado Pago Java SDK. It exposes a set of static, volatile fields that govern every API call made from the current JVM process — authentication credentials, HTTP timeouts, connection pooling, logging verbosity, proxy routing, custom retry logic, and the underlying HTTP client implementation. Because all configurable fields are declared volatile (or synchronized for compound operations), you can safely set them from any thread at application startup without additional locking.
Per-request overrides are also available via MPRequestOptions, which lets you change the access token, timeouts, or headers for a single call without touching global state. See Per-Request Overrides below.
Global Configuration Reference
The following table lists every configurable property onMercadoPagoConfig, its type, default value, and purpose.
| Property | Type | Default | Description |
|---|---|---|---|
accessToken | String | null | OAuth access token used to authenticate all API requests. Must be set before making any call. |
platformId | String | null | Platform identifier sent as a request header for analytics and tracking. |
corporationId | String | null | Corporation identifier header for multi-entity traffic attribution. |
integratorId | String | null | Integrator identifier header to attribute API traffic to a specific integration partner. |
loggingLevel | java.util.logging.Level | Level.OFF | Verbosity of SDK log output. Set to Level.FINEST for full request/response logging. |
loggingHandler | java.util.logging.StreamHandler | null | Custom log handler. When null, a default ConsoleHandler writing to System.err is used. |
metricsScope | String | "prod" | Scope label included in SDK metrics reporting. |
maxConnections | int | 10 | Maximum number of concurrent HTTP connections maintained in the connection pool. |
connectionTimeout | int | 20000 | Timeout in milliseconds for establishing a new HTTP connection. |
connectionRequestTimeout | int | 20000 | Timeout in milliseconds for obtaining a leased connection from the pool. |
socketTimeout | int | 20000 | Socket read timeout in milliseconds — how long to wait for response data after the connection is established. |
httpClient | MPHttpClient | MPDefaultHttpClient | Pluggable HTTP client. Lazily initialized to MPDefaultHttpClient on first use; replace with a custom implementation via setHttpClient(). |
proxy | org.apache.http.HttpHost | null | HTTP proxy host through which all API requests are routed. null means direct connection. |
retryHandler | org.apache.http.client.HttpRequestRetryHandler | null | Custom retry logic delegate. When set, the Apache HTTP client defers retry decisions to this handler. |
Property Details
The OAuth bearer token used to authenticate every API request. Obtain yours from the Mercado Pago Developer Panel. Can be overridden per-request via
MPRequestOptions.accessToken.Sent as the
x-platform-id header on every request. Used by Mercado Pago to identify the platform or framework generating traffic (e.g., a specific e-commerce platform integration).Sent as the
x-corporation-id header. Used in multi-entity deployments to attribute traffic to a specific corporate account.Sent as the
x-integrator-id header to identify the integration partner or agency responsible for the integration.Controls SDK log verbosity using the standard
java.util.logging levels. Level.OFF (default) disables all output. Use Level.FINEST to log full request and response details during development.A custom
StreamHandler to receive SDK log records. When not set, the SDK creates a ConsoleHandler writing to System.err. Supply a FileHandler or a handler that bridges to your application’s logging framework.A label included in internal SDK metrics payloads. Change to
"sandbox" or a custom value when you need to distinguish metric traffic from non-production environments.The maximum number of concurrent HTTP connections the pool maintains. Increase this value for high-throughput applications that issue many concurrent API requests.
Milliseconds to wait when establishing a new TCP connection to the Mercado Pago API. A value of
0 means wait indefinitely.Milliseconds to wait for an available connection to be leased from the pool. Relevant when all pool connections are busy. A value of
0 means wait indefinitely.Milliseconds to wait for data after a connection is established — essentially the read timeout. Tune this down if you need fast failure detection, or up for slow payment method flows.
The
MPHttpClient implementation used for all API calls. Defaults to MPDefaultHttpClient (Apache HttpClient 4.x / 5.x based). Replace with a custom implementation to add instrumentation, circuit-breaking, or an alternative HTTP library.An Apache
HttpHost describing the HTTP proxy through which all API requests are routed. Set to null (the default) to connect directly.A custom
HttpRequestRetryHandler that decides whether a failed request should be retried. When not set, the Apache HTTP client uses its default retry strategy (no retries on I/O exceptions for non-idempotent methods).Configuration Examples
Setting Timeouts
Tune all three timeout values together for a tighter latency budget in production:All timeout values are in milliseconds. A value of
0 means wait indefinitely — avoid this in production.Enabling Logging
The SDK usesjava.util.logging. Set loggingLevel to any standard Level to enable output. Use Level.FINEST during development to inspect raw HTTP request and response details.
FileHandler:
Configuring a Proxy
Route all SDK traffic through an HTTP proxy by setting an ApacheHttpHost:
The
proxy field uses synchronized getters and setters internally, so it is safe to change at runtime from any thread.Custom HTTP Client
Replace the defaultMPDefaultHttpClient with your own implementation of the MPHttpClient interface. This is useful when you need to add instrumentation (e.g., Micrometer metrics, OpenTelemetry spans), plug in a circuit breaker, or use a different HTTP library entirely.
The MPHttpClient interface requires a single method:
MercadoPagoConfig before creating any SDK client objects:
Per-Request Overrides
MPRequestOptions lets you override MercadoPagoConfig values for a single API call without affecting global state. Any field left at 0 (for int) or null (for objects) falls back to the global configuration automatically.
MPRequestOptions supports the following overridable fields:
| Field | Type | Description |
|---|---|---|
accessToken | String | Per-request OAuth token. Overrides MercadoPagoConfig.accessToken. |
connectionTimeout | int | Per-request connection timeout (ms). 0 uses global default. |
connectionRequestTimeout | int | Per-request pool lease timeout (ms). 0 uses global default. |
socketTimeout | int | Per-request socket read timeout (ms). 0 uses global default. |
customHeaders | Map<String, String> | Additional HTTP headers merged into the request (e.g., idempotency keys). |
Thread Safety
All fields inMercadoPagoConfig are declared volatile so that writes from one thread are immediately visible to all other threads without explicit synchronization. The proxy field uses synchronized accessors for compound read-modify operations. The httpClient field is lazily initialized via a synchronized method.
Configure
MercadoPagoConfig once at application startup — ideally in a static initializer block or an application lifecycle hook — before any client objects are created. Changing global configuration mid-flight in a multi-threaded environment is safe at the volatile memory level, but can produce surprising behavior if in-flight requests read different settings than the ones that were active when the request was initiated.