Skip to content

feat: add support for customer headers / idemptotency key#335

Open
cbarton wants to merge 2 commits into
v3-v2021-02-25from
request-options
Open

feat: add support for customer headers / idemptotency key#335
cbarton wants to merge 2 commits into
v3-v2021-02-25from
request-options

Conversation

@cbarton

@cbarton cbarton commented Jul 21, 2026

Copy link
Copy Markdown
Member

Every operation on the client has an overload that accepts a RequestOptions object. Use it to set per-request options such as an idempotency key.

Idempotency Keys

import com.recurly.v3.RequestOptions;
import com.recurly.v3.requests.AccountCreate;
import com.recurly.v3.resources.Account;

final AccountCreate accountReq = new AccountCreate();
accountReq.setCode("myaccountcode");

final RequestOptions options = RequestOptions.builder()
    .idempotencyKey("unique-key-for-this-operation")
    .build();

final Account account = client.createAccount(accountReq, options);

Custom Headers

final RequestOptions options = RequestOptions.builder()
    .header("X-Custom-Header", "value")
    .header("X-Another-Header", "other-value")
    .build();

final Account account = client.createAccount(accountReq, options);

Options can be combined — idempotencyKey and header calls chain together:

final RequestOptions options = RequestOptions.builder()
    .idempotencyKey("unique-key")
    .header("X-Custom-Header", "value")
    .build();

@cbarton cbarton added the V6 v2021-02-25 Client label Jul 21, 2026
Comment thread src/main/java/com/recurly/v3/BaseClient.java Outdated
Comment thread src/main/java/com/recurly/v3/RequestOptions.java Outdated
cbarton added 2 commits July 22, 2026 09:47
Every operation on the client has an overload that accepts a `RequestOptions` object. Use it to set
per-request options such as an idempotency key.

Idempotency Keys

```java
import com.recurly.v3.RequestOptions;
import com.recurly.v3.requests.AccountCreate;
import com.recurly.v3.resources.Account;

final AccountCreate accountReq = new AccountCreate();
accountReq.setCode("myaccountcode");

final RequestOptions options = RequestOptions.builder()
    .idempotencyKey("unique-key-for-this-operation");

final Account account = client.createAccount(accountReq, options);
```

Custom Headers

```java
final RequestOptions options = RequestOptions.builder()
    .header("X-Custom-Header", "value")
    .header("X-Another-Header", "other-value");

final Account account = client.createAccount(accountReq, options);
```

Options can be combined — `idempotencyKey` and `header` calls chain together:

```java
final RequestOptions options = RequestOptions.builder()
    .idempotencyKey("unique-key")
    .header("X-Custom-Header", "value");
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

V6 v2021-02-25 Client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants