Python
import os, sodacards
from sodacards.models import SodacardsDevpublicV1RegisterWebhookRequest
config = sodacards.Configuration(host="https://api.sodacards.com")
config.api_key["ApiKeyAuth"] = os.environ["SODACARDS_API_KEY"]
client = sodacards.DefaultApi(sodacards.ApiClient(config))
webhook = client.register_webhook(
SodacardsDevpublicV1RegisterWebhookRequest(
url="https://example.com/webhooks/sodacards",
events=["order.fulfilled", "order.refunded"],
)
)import { Sodacards } from "@sodacards/sdk";
const sodacards = new Sodacards({ apiKeyAuth: process.env.SODACARDS_API_KEY });
const webhook = await sodacards.registerWebhook({
url: "https://example.com/webhooks/sodacards",
events: ["order.fulfilled", "order.refunded"],
});client := sodacards.NewAPIClient(sodacards.NewConfiguration())
auth := context.WithValue(context.Background(), sodacards.ContextAPIKeys,
map[string]sodacards.APIKey{"ApiKeyAuth": {Key: os.Getenv("SODACARDS_API_KEY")}})
body := sodacards.NewSodacardsDevpublicV1RegisterWebhookRequest()
body.SetUrl("https://example.com/webhooks/sodacards")
body.SetEvents([]string{"order.fulfilled", "order.refunded"})
webhook, _, err := client.DefaultAPI.RegisterWebhook(auth).
SodacardsDevpublicV1RegisterWebhookRequest(*body).
Execute()$config = Sodacards\Configuration::getDefaultConfiguration()
->setApiKey('X-API-Key', getenv('SODACARDS_API_KEY'));
$client = new Sodacards\Api\DefaultApi(new GuzzleHttp\Client(), $config);
$webhook = $client->registerWebhook(new Sodacards\Model\SodacardsDevpublicV1RegisterWebhookRequest([
'url' => 'https://example.com/webhooks/sodacards',
'events' => ['order.fulfilled', 'order.refunded'],
]));curl --request POST \
--url https://api.sodacards.com/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"url": "<string>",
"events": [
"<string>"
]
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>', events: ['<string>']})
};
fetch('https://api.sodacards.com/v1/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.sodacards.com/v1/webhooks")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"events\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sodacards.com/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"events\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"webhook": {
"id": "<string>",
"url": "<string>",
"events": [
"<string>"
],
"active": true,
"createdAt": "<string>"
},
"secret": "<string>"
}API Reference
RegisterWebhook
RegisterWebhook registers a URL to receive signed event deliveries. The URL must be HTTPS and publicly routable. The response carries the signing secret once; store it, as it is never shown again.
POST
/
v1
/
webhooks
Python
import os, sodacards
from sodacards.models import SodacardsDevpublicV1RegisterWebhookRequest
config = sodacards.Configuration(host="https://api.sodacards.com")
config.api_key["ApiKeyAuth"] = os.environ["SODACARDS_API_KEY"]
client = sodacards.DefaultApi(sodacards.ApiClient(config))
webhook = client.register_webhook(
SodacardsDevpublicV1RegisterWebhookRequest(
url="https://example.com/webhooks/sodacards",
events=["order.fulfilled", "order.refunded"],
)
)import { Sodacards } from "@sodacards/sdk";
const sodacards = new Sodacards({ apiKeyAuth: process.env.SODACARDS_API_KEY });
const webhook = await sodacards.registerWebhook({
url: "https://example.com/webhooks/sodacards",
events: ["order.fulfilled", "order.refunded"],
});client := sodacards.NewAPIClient(sodacards.NewConfiguration())
auth := context.WithValue(context.Background(), sodacards.ContextAPIKeys,
map[string]sodacards.APIKey{"ApiKeyAuth": {Key: os.Getenv("SODACARDS_API_KEY")}})
body := sodacards.NewSodacardsDevpublicV1RegisterWebhookRequest()
body.SetUrl("https://example.com/webhooks/sodacards")
body.SetEvents([]string{"order.fulfilled", "order.refunded"})
webhook, _, err := client.DefaultAPI.RegisterWebhook(auth).
SodacardsDevpublicV1RegisterWebhookRequest(*body).
Execute()$config = Sodacards\Configuration::getDefaultConfiguration()
->setApiKey('X-API-Key', getenv('SODACARDS_API_KEY'));
$client = new Sodacards\Api\DefaultApi(new GuzzleHttp\Client(), $config);
$webhook = $client->registerWebhook(new Sodacards\Model\SodacardsDevpublicV1RegisterWebhookRequest([
'url' => 'https://example.com/webhooks/sodacards',
'events' => ['order.fulfilled', 'order.refunded'],
]));curl --request POST \
--url https://api.sodacards.com/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"url": "<string>",
"events": [
"<string>"
]
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>', events: ['<string>']})
};
fetch('https://api.sodacards.com/v1/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.sodacards.com/v1/webhooks")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"events\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sodacards.com/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"events\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"webhook": {
"id": "<string>",
"url": "<string>",
"events": [
"<string>"
],
"active": true,
"createdAt": "<string>"
},
"secret": "<string>"
}Authorizations
Your API key, prefixed sc_live_ or sc_test_.
Body
application/json
⌘I