import CheckoutIntents from 'checkout-intents';
const client = new CheckoutIntents({
apiKey: process.env['CHECKOUT_INTENTS_API_KEY'], // This is the default and can be omitted
});
const _return = await client.returns.create({ orderId: 'orderId', reason: 'defective' });
console.log(_return.id);import os
from checkout_intents import CheckoutIntents
client = CheckoutIntents(
api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"), # This is the default and can be omitted
)
return_ = client.returns.create(
order_id="orderId",
reason="defective",
)
print(return_.id)package com.rye.example;
import com.rye.client.CheckoutIntentsClient;
import com.rye.client.okhttp.CheckoutIntentsOkHttpClient;
import com.rye.models.returns.Return;
import com.rye.models.returns.ReturnCreateParams;
import com.rye.models.returns.ReturnReason;
public final class Main {
private Main() {}
public static void main(String[] args) {
CheckoutIntentsClient client = CheckoutIntentsOkHttpClient.fromEnv();
ReturnCreateParams params = ReturnCreateParams.builder()
.orderId("orderId")
.reason(ReturnReason.DEFECTIVE)
.build();
Return return_ = client.returns().create(params);
}
}curl https://staging.api.rye.com/api/v1/returns \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CHECKOUT_INTENTS_API_KEY" \
-d '{
"orderId": "orderId",
"reason": "defective"
}'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.api.rye.com/api/v1/returns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'orderId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging.api.rye.com/api/v1/returns"
payload := strings.NewReader("{\n \"orderId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://staging.api.rye.com/api/v1/returns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"orderId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"updatedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"timeline": {
"requestedAt": "2023-11-07T05:31:56Z",
"failedAt": "2023-11-07T05:31:56Z",
"deniedAt": "2023-11-07T05:31:56Z",
"refundedAt": "2023-11-07T05:31:56Z",
"refundIssuedAt": "2023-11-07T05:31:56Z",
"returnApprovedAt": "2023-11-07T05:31:56Z"
},
"reason": "defective",
"checkoutIntentId": "<string>",
"orderId": "<string>",
"state": "requested",
"id": "<string>",
"refunds": [
{
"shopperRefundTotal": {
"currencyCode": "USD",
"amountSubunits": 1500
},
"refundedAt": "2023-11-07T05:31:56Z",
"id": "<string>"
}
],
"failure": {
"message": "<string>",
"code": "drawdown_credit_failed"
},
"denial": {
"reason": "final_sale",
"note": "<string>"
},
"nextAction": {
"type": "ship_items_to_merchant",
"shipItemsToMerchant": {
"label": {
"url": "<string>"
}
}
}
}{
"name": "<string>",
"message": "<string>",
"stack": "<string>"
}{
"name": "<string>",
"message": "<string>",
"stack": "<string>"
}{
"name": "<string>",
"message": "<string>",
"status": 123,
"fields": {},
"stack": "<string>"
}{
"name": "<string>",
"message": "<string>",
"stack": "<string>"
}Create return
Create a return for a completed order. Whole-order returns only — the order’s line items are enumerated for you. The return is submitted for approval and then progresses asynchronously toward the refund; poll the returned return id (or listen for webhooks) to follow its state.
import CheckoutIntents from 'checkout-intents';
const client = new CheckoutIntents({
apiKey: process.env['CHECKOUT_INTENTS_API_KEY'], // This is the default and can be omitted
});
const _return = await client.returns.create({ orderId: 'orderId', reason: 'defective' });
console.log(_return.id);import os
from checkout_intents import CheckoutIntents
client = CheckoutIntents(
api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"), # This is the default and can be omitted
)
return_ = client.returns.create(
order_id="orderId",
reason="defective",
)
print(return_.id)package com.rye.example;
import com.rye.client.CheckoutIntentsClient;
import com.rye.client.okhttp.CheckoutIntentsOkHttpClient;
import com.rye.models.returns.Return;
import com.rye.models.returns.ReturnCreateParams;
import com.rye.models.returns.ReturnReason;
public final class Main {
private Main() {}
public static void main(String[] args) {
CheckoutIntentsClient client = CheckoutIntentsOkHttpClient.fromEnv();
ReturnCreateParams params = ReturnCreateParams.builder()
.orderId("orderId")
.reason(ReturnReason.DEFECTIVE)
.build();
Return return_ = client.returns().create(params);
}
}curl https://staging.api.rye.com/api/v1/returns \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CHECKOUT_INTENTS_API_KEY" \
-d '{
"orderId": "orderId",
"reason": "defective"
}'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.api.rye.com/api/v1/returns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'orderId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging.api.rye.com/api/v1/returns"
payload := strings.NewReader("{\n \"orderId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://staging.api.rye.com/api/v1/returns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"orderId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"updatedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"timeline": {
"requestedAt": "2023-11-07T05:31:56Z",
"failedAt": "2023-11-07T05:31:56Z",
"deniedAt": "2023-11-07T05:31:56Z",
"refundedAt": "2023-11-07T05:31:56Z",
"refundIssuedAt": "2023-11-07T05:31:56Z",
"returnApprovedAt": "2023-11-07T05:31:56Z"
},
"reason": "defective",
"checkoutIntentId": "<string>",
"orderId": "<string>",
"state": "requested",
"id": "<string>",
"refunds": [
{
"shopperRefundTotal": {
"currencyCode": "USD",
"amountSubunits": 1500
},
"refundedAt": "2023-11-07T05:31:56Z",
"id": "<string>"
}
],
"failure": {
"message": "<string>",
"code": "drawdown_credit_failed"
},
"denial": {
"reason": "final_sale",
"note": "<string>"
},
"nextAction": {
"type": "ship_items_to_merchant",
"shipItemsToMerchant": {
"label": {
"url": "<string>"
}
}
}
}{
"name": "<string>",
"message": "<string>",
"stack": "<string>"
}{
"name": "<string>",
"message": "<string>",
"stack": "<string>"
}{
"name": "<string>",
"message": "<string>",
"status": 123,
"fields": {},
"stack": "<string>"
}{
"name": "<string>",
"message": "<string>",
"stack": "<string>"
}Authorizations
Rye API key
Body
Request body for POST /api/v1/returns. Whole-order returns only —
server enumerates the order's line items at create time.
Response
Created
A single Return record. The state discriminator tells you which of
denial, failure, and refunds is populated; nextAction is set once the
Return is approved (see {@link NextActionResponse}).
When the Return record was last updated.
When the Return record was created.
Per-transition timestamps; later stamps fill in as the Return advances.
Show child attributes
Show child attributes
Reason the return was requested, echoed back from the create call.
defective, wrong_item, unwanted, color, not_as_described, size_too_large, size_too_small, style, other Rye checkout intent id that produced the order being returned.
Rye order id (order_<32 hex>) this Return was opened against.
Lifecycle state; the discriminator for the optional sub-objects below.
requested, requires_action, processing, refunded, denied, failed Rye return id (ret_<32 hex>).
Issued refunds. Present only on refunded.
Show child attributes
Show child attributes
What went wrong. Present only on failed.
Show child attributes
Show child attributes
Why the merchant declined the return. Present only on denied.
Show child attributes
Show child attributes
What the shopper must do next (e.g. ship the items back). Present once the
return is approved — i.e. on requires_action, processing, and
refunded — and may be present on denied / failed if they were
approved before terminating. Absent on requested.
Show child attributes
Show child attributes
Was this page helpful?

