curl -X POST https://simplewebapis.com/api/invoice \
-H "Content-Type: application/json" \
-H "X-Api-Key: swa_your_key" \
-d '{
"invoiceNumber": 1001,
"seller": { "name": "Acme Corp", "addressLines": ["123 Seller St", "San Francisco, CA 94105"], "email": "[email protected]" },
"customer": { "name": "Globex Inc", "addressLines": ["456 Customer Ave", "New York, NY 10001"], "email": "[email protected]" },
"items": [
{ "name": "Web Development", "price": 1500.00, "quantity": 1 },
{ "name": "UI Design", "price": 800.00, "quantity": 2 }
],
"comments": "Thank you for your business!",
"currency": "USD",
"logoUrl": "https://simplewebapis.com/favicon-32x32.png",
"accentColor": "#2563EB",
"separatorColor": "#E5E7EB",
"commentsBackgroundColor": "#F9FAFB"
}' --output invoice.pdf
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "swa_your_key");
var payload = new
{
invoiceNumber = 1001,
seller = new { name = "Acme Corp", addressLines = new[] { "123 Seller St", "San Francisco, CA 94105" }, email = "[email protected]" },
customer = new { name = "Globex Inc", addressLines = new[] { "456 Customer Ave", "New York, NY 10001" }, email = "[email protected]" },
items = new[]
{
new { name = "Web Development", price = 1500.00m, quantity = 1 },
new { name = "UI Design", price = 800.00m, quantity = 2 }
},
comments = "Thank you for your business!",
Currency = "USD",
LogoUrl = "https://simplewebapis.com/favicon-32x32.png",
accentColor = "#2563EB",
separatorColor = "#E5E7EB",
commentsBackgroundColor = "#F9FAFB"
};
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://simplewebapis.com/api/invoice", content);
var pdfBytes = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("invoice.pdf", pdfBytes);
$payload = json_encode([
'invoiceNumber' => 1001,
'seller' => ['name' => 'Acme Corp', 'addressLines' => ['123 Seller St', 'San Francisco, CA 94105'], 'email' => '[email protected]'],
'customer' => ['name' => 'Globex Inc', 'addressLines' => ['456 Customer Ave', 'New York, NY 10001'], 'email' => '[email protected]'],
'items' => [
['name' => 'Web Development', 'price' => 1500.00, 'quantity' => 1],
['name' => 'UI Design', 'price' => 800.00, 'quantity' => 2],
],
'comments' => 'Thank you for your business!',
'currency' => 'USD',
'logoUrl' => 'https://simplewebapis.com/favicon-32x32.png',
'accentColor' => '#2563EB',
'separatorColor' => '#E5E7EB',
'commentsBackgroundColor' => '#F9FAFB',
]);
$ch = curl_init('https://simplewebapis.com/api/invoice');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Api-Key: swa_your_key',
],
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
]);
$pdf = curl_exec($ch);
curl_close($ch);
file_put_contents('invoice.pdf', $pdf);
const response = await fetch('https://simplewebapis.com/api/invoice', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': 'swa_your_key',
},
body: JSON.stringify({
invoiceNumber: 1001,
seller: { name: 'Acme Corp', addressLines: ['123 Seller St', 'San Francisco, CA 94105'], email: '[email protected]' },
customer: { name: 'Globex Inc', addressLines: ['456 Customer Ave', 'New York, NY 10001'], email: '[email protected]' },
items: [
{ name: 'Web Development', price: 1500.00, quantity: 1 },
{ name: 'UI Design', price: 800.00, quantity: 2 },
],
comments: 'Thank you for your business!',
currency: 'USD',
logoUrl: 'https://simplewebapis.com/favicon-32x32.png',
accentColor: '#2563EB',
separatorColor: '#E5E7EB',
commentsBackgroundColor: '#F9FAFB',
}),
});
const buffer = await response.arrayBuffer();
const fs = require('fs');
fs.writeFileSync('invoice.pdf', Buffer.from(buffer));
import requests
response = requests.post(
'https://simplewebapis.com/api/invoice',
headers={
'Content-Type': 'application/json',
'X-Api-Key': 'swa_your_key',
},
json={
'invoiceNumber': 1001,
'seller': {'name': 'Acme Corp', 'addressLines': ['123 Seller St', 'San Francisco, CA 94105'], 'email': '[email protected]'},
'customer': {'name': 'Globex Inc', 'addressLines': ['456 Customer Ave', 'New York, NY 10001'], 'email': '[email protected]'},
'items': [
{'name': 'Web Development', 'price': 1500.00, 'quantity': 1},
{'name': 'UI Design', 'price': 800.00, 'quantity': 2},
],
'comments': 'Thank you for your business!',
'currency': 'USD',
'logoUrl': 'https://simplewebapis.com/favicon-32x32.png',
'accentColor': '#2563EB',
'separatorColor': '#E5E7EB',
'commentsBackgroundColor': '#F9FAFB',
},
)
with open('invoice.pdf', 'wb') as f:
f.write(response.content)
payload := map[string]interface{}{
"invoiceNumber": 1001,
"seller": map[string]interface{}{
"name": "Acme Corp",
"addressLines": []string{"123 Seller St", "San Francisco, CA 94105"},
"email": "[email protected]",
},
"customer": map[string]interface{}{
"name": "Globex Inc",
"addressLines": []string{"456 Customer Ave", "New York, NY 10001"},
"email": "[email protected]",
},
"items": []map[string]interface{}{
{"name": "Web Development", "price": 1500.00, "quantity": 1},
{"name": "UI Design", "price": 800.00, "quantity": 2},
},
"comments": "Thank you for your business!",
"currency": "USD",
"logoUrl": "https://simplewebapis.com/favicon-32x32.png",
"accentColor": "#2563EB",
"separatorColor": "#E5E7EB",
"commentsBackgroundColor": "#F9FAFB",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://simplewebapis.com/api/invoice",
bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Api-Key", "swa_your_key")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
os.WriteFile("invoice.pdf", body, 0644)
require 'net/http'
require 'json'
require 'uri'
payload = {
invoiceNumber: 1001,
seller: { name: 'Acme Corp', addressLines: ['123 Seller St', 'San Francisco, CA 94105'], email: '[email protected]' },
customer: { name: 'Globex Inc', addressLines: ['456 Customer Ave', 'New York, NY 10001'], email: '[email protected]' },
items: [
{ name: 'Web Development', price: 1500.00, quantity: 1 },
{ name: 'UI Design', price: 800.00, quantity: 2 },
],
comments: 'Thank you for your business!',
currency: 'USD',
logo_url: 'https://simplewebapis.com/favicon-32x32.png',
accentColor: '#2563EB',
separatorColor: '#E5E7EB',
commentsBackgroundColor: '#F9FAFB',
}
uri = URI('https://simplewebapis.com/api/invoice')
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/json'
req['X-Api-Key'] = 'swa_your_key'
req.body = payload.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
File.binwrite('invoice.pdf', response.body)
var payload = """
{
"invoiceNumber": 1001,
"seller": { "name": "Acme Corp", "addressLines": ["123 Seller St", "San Francisco, CA 94105"], "email": "[email protected]" },
"customer": { "name": "Globex Inc", "addressLines": ["456 Customer Ave", "New York, NY 10001"], "email": "[email protected]" },
"items": [
{ "name": "Web Development", "price": 1500.00, "quantity": 1 },
{ "name": "UI Design", "price": 800.00, "quantity": 2 }
],
"comments": "Thank you for your business!",
"currency": "USD",
"logoUrl": "https://simplewebapis.com/favicon-32x32.png",
"accentColor": "#2563EB",
"separatorColor": "#E5E7EB",
"commentsBackgroundColor": "#F9FAFB"
}
""";
var request = HttpRequest.newBuilder()
.uri(URI.create("https://simplewebapis.com/api/invoice"))
.header("Content-Type", "application/json")
.header("X-Api-Key", "swa_your_key")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
var response = HttpClient.newHttpClient().send(request,
HttpResponse.BodyHandlers.ofByteArray());
Files.write(Path.of("invoice.pdf"), response.body());
use serde_json::json;
use std::fs;
let client = reqwest::Client::new();
let payload = json!({
"invoiceNumber": 1001,
"seller": { "name": "Acme Corp", "addressLines": ["123 Seller St", "San Francisco, CA 94105"], "email": "[email protected]" },
"customer": { "name": "Globex Inc", "addressLines": ["456 Customer Ave", "New York, NY 10001"], "email": "[email protected]" },
"items": [
{ "name": "Web Development", "price": 1500.00, "quantity": 1 },
{ "name": "UI Design", "price": 800.00, "quantity": 2 }
],
"comments": "Thank you for your business!",
"currency": "USD",
"logoUrl": "https://simplewebapis.com/favicon-32x32.png",
"accentColor": "#2563EB",
"separatorColor": "#E5E7EB",
"commentsBackgroundColor": "#F9FAFB"
});
let resp = client.post("https://simplewebapis.com/api/invoice")
.header("Content-Type", "application/json")
.header("X-Api-Key", "swa_your_key")
.json(&payload)
.send()
.await?;
let bytes = resp.bytes().await?;
fs::write("invoice.pdf", &bytes)?;