Update Coupon
Modify the metadata of a coupon.
This method triggers the Coupon Updated webhook. This webhook contains the same information as the response.
coupon
ID of the coupon. String starting with coupon_.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { var coupon = "coupon_78a69ea113bccfc8a186061e0b96336d"; var requestObj = new { metadata = new { coupon_type = "Holiday promotional" } }; string request = JsonSerializer.Serialize(requestObj); string result = RapydApiRequestSample.Utilities.MakeRequest("POST", "/v1/coupons/{coupon}", request); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Error completing request: " + e.Message); } } } }
JavaScript
const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest; async function main() { try { const body = { metadata: { coupon_type: 'Holiday promotional' } }; const result = await makeRequest( 'POST', '/v1/coupons/coupon_78a69ea113bccfc8a186061e0b96336d', body ); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); $body = [ "metadata" => array( "coupon_type" => "Holiday promotional" ) ]; try { $object = make_request('post', "/v1/coupons/coupon_78a69ea113bccfc8a186061e0b96336d", $body); var_dump($object); } catch (Exception $e) { echo "Error =>$e"; } ?>
Python
from pprint import pprint from utilities import make_request coupon_id = "coupon_78a69ea113bccfc8a186061e0b96336d" coupon_data = { "metadata": { "coupon_type": "Holiday promotional" } } result = make_request(method='post', path=f'/v1/coupons/{coupon_id}', body=coupon_data) pprint(result)
/v1/coupons/:coupon
Update Coupon
curl -X post https://sandboxapi.rapyd.net/v1/coupons/coupon_72b8f33846b06f9e7fb0d12cccf98061 -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here' -d '{ "metadata": { "coupon_type": "Holiday promotional" } } '
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "4d29f036-d383-4279-adde-2f22452ce5ad" }, "data": { "id": "coupon_72b8f33846b06f9e7fb0d12cccf98061", "amount_off": 0, "created": 1646817710, "currency": "", "duration": "repeating", "duration_in_months": 3, "max_redemptions": 0, "metadata": { "coupon_type": "Holiday promotional" }, "percent_off": 10, "redeem_by": 0, "times_redeemed": 0, "discount_valid_until": 0, "discount_validity_in_months": 0, "discount_duration_in_uses": 0, "description": "", "valid": false } }