Purchase a points product
curl --request POST \
--url https://api.smile.io/v1/points_products/{id}/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": 304169228,
"points_to_spend": 500
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.smile.io/v1/points_products/{id}/purchase"
payload := strings.NewReader("{\n \"customer_id\": 304169228,\n \"points_to_spend\": 500\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api.smile.io/v1/points_products/{id}/purchase")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 304169228,\n \"points_to_spend\": 500\n}")
.asString();const url = 'https://api.smile.io/v1/points_products/{id}/purchase';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer_id: 304169228, points_to_spend: 500})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.smile.io/v1/points_products/{id}/purchase",
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([
'customer_id' => 304169228,
'points_to_spend' => 500
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}$headers=@{}
$headers.Add("Authorization", "Bearer <token>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://api.smile.io/v1/points_products/{id}/purchase' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"customer_id": 304169228,
"points_to_spend": 500
}'import requests
url = "https://api.smile.io/v1/points_products/{id}/purchase"
payload = {
"customer_id": 304169228,
"points_to_spend": 500
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)require 'uri'
require 'net/http'
url = URI("https://api.smile.io/v1/points_products/{id}/purchase")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": 304169228,\n \"points_to_spend\": 500\n}"
response = http.request(request)
puts response.read_body{
"points_purchase": {
"id": 665523890,
"customer_id": 304169228,
"points_product_id": 132456921,
"points_spent": 500,
"reward_fulfillment": {
"id": 625478984,
"name": "$5 off coupon",
"code": "5off-e26d02e39149",
"customer_id": 304169228,
"fulfillment_status": "issued",
"image_url": "https://platform-images.smilecdn.co/9283449.png",
"action_text": "<string>",
"action_url": "<string>",
"usage_instructions": "Use this discount code on your next order!",
"terms_and_conditions": "Reward expires on June 7, 2025. Reward can only be used on purchase of $50 or more. Reward can only be used on select product collections.",
"expires_at": "2025-06-07T23:59:59.999Z",
"usage_status": "unused",
"used_at": "2023-11-07T05:31:56Z",
"created_at": "2024-12-07T20:15:27.893Z",
"updated_at": "2024-12-07T20:15:27.893Z"
},
"created_at": "2024-04-04T15:10:42.030Z",
"updated_at": "2024-04-04T15:10:42.030Z"
}
}Points Products
Purchase a points product
Purchase a points product on behalf of a customer in the Smile REST API.
POST
/
points_products
/
{id}
/
purchase
Purchase a points product
curl --request POST \
--url https://api.smile.io/v1/points_products/{id}/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": 304169228,
"points_to_spend": 500
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.smile.io/v1/points_products/{id}/purchase"
payload := strings.NewReader("{\n \"customer_id\": 304169228,\n \"points_to_spend\": 500\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api.smile.io/v1/points_products/{id}/purchase")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 304169228,\n \"points_to_spend\": 500\n}")
.asString();const url = 'https://api.smile.io/v1/points_products/{id}/purchase';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer_id: 304169228, points_to_spend: 500})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.smile.io/v1/points_products/{id}/purchase",
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([
'customer_id' => 304169228,
'points_to_spend' => 500
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}$headers=@{}
$headers.Add("Authorization", "Bearer <token>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://api.smile.io/v1/points_products/{id}/purchase' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"customer_id": 304169228,
"points_to_spend": 500
}'import requests
url = "https://api.smile.io/v1/points_products/{id}/purchase"
payload = {
"customer_id": 304169228,
"points_to_spend": 500
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)require 'uri'
require 'net/http'
url = URI("https://api.smile.io/v1/points_products/{id}/purchase")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": 304169228,\n \"points_to_spend\": 500\n}"
response = http.request(request)
puts response.read_body{
"points_purchase": {
"id": 665523890,
"customer_id": 304169228,
"points_product_id": 132456921,
"points_spent": 500,
"reward_fulfillment": {
"id": 625478984,
"name": "$5 off coupon",
"code": "5off-e26d02e39149",
"customer_id": 304169228,
"fulfillment_status": "issued",
"image_url": "https://platform-images.smilecdn.co/9283449.png",
"action_text": "<string>",
"action_url": "<string>",
"usage_instructions": "Use this discount code on your next order!",
"terms_and_conditions": "Reward expires on June 7, 2025. Reward can only be used on purchase of $50 or more. Reward can only be used on select product collections.",
"expires_at": "2025-06-07T23:59:59.999Z",
"usage_status": "unused",
"used_at": "2023-11-07T05:31:56Z",
"created_at": "2024-12-07T20:15:27.893Z",
"updated_at": "2024-12-07T20:15:27.893Z"
},
"created_at": "2024-04-04T15:10:42.030Z",
"updated_at": "2024-04-04T15:10:42.030Z"
}
}This endpoint requires the scope.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
ID of the points product to purchase.
Example:
132456921
Body
application/json
ID of the customer who is purchasing the points product.
Example:
304169228
The number of points that will be spent on behalf of the customer. Only applies when purchasing a points product whose exchange_type is variable, otherwise should be left blank.
Example:
500
Response
201 - application/json
The points product was successfully purchased.
Show child attributes
Show child attributes
⌘I