{"id":"pg_icmniccuptfb","property_id":"prp_pfcr5h8cztsp","domain_id":"dom_gkgeprhezjg4wq","root_domain":"smashsend.com","locale":"en","url":"https://smashsend.com/docs/api/tutorial","url_hash":"3a278c79f6f330d65e118e4087cb54fe12b4de7df56d861b9e12a5e69c0aa2ad","path":"/docs/api/tutorial","depth":1,"canonical_url":"https://smashsend.com/docs/api/tutorial","canonical_page_id":null,"page_type":"docs","page_type_guess":"docs","state":"indexed","skip_reason":null,"priority":"1.4","discovered_via":"sitemap","first_seen_at":"2026-08-28T03:07:01.092Z","last_seen_at":"2026-09-27T04:10:47.779Z","http_status":200,"content_hash":"91930679247c6bde88f6ff8f361be366ec8a7a62f6b0339dcd4ab8d6abb35a11","title":"SMASHSEND API Tutorial","description":"A step-by-step tutorial to get started with the SMASHSEND API.","author":null,"published_at":null,"modified_at":null,"word_count":663,"reading_time_sec":181,"lang_detected":"en","images":[],"links_out":null,"markdown_source":"readability","refresh_interval":"monthly","last_fetched_at":"2026-09-27T04:09:24.562Z","next_refresh_at":"2026-10-27T04:09:24.562Z","runs_count":2,"changes_count":0,"last_changed_at":null,"fail_count":0,"last_error":null,"created_at":"2026-08-28T03:07:01.092Z","updated_at":"2026-08-28T03:07:01.092Z","inlinks":13,"inlinks_body":0,"outlinks":40,"outlinks_external":3,"anchor_terms":[],"template_score":"0.09154929577464788732","cash":"0.202437454962348177","cash_total":"0.6292854667854735652","pagerank":"0.0162500817959562","is_orphan":false,"link_confirmed":true,"discovered_wave":0,"embedded_hash":null,"embedded_at":null,"domain_name":null,"brand_color":null,"domain_rank":null,"spam_score":null,"markdown":"This step-by-step tutorial will guide you through integrating with the SMASHSEND API. Learn how to authenticate, create resources, and handle responses.\n\n## Prerequisites\n\nBefore starting, make sure you have:\n\n-   A SMASHSEND account with API access\n    \n-   An API key (which you can get from your dashboard)\n    \n-   Basic understanding of REST APIs and HTTP requests\n    \n\n## Step 1: Authentication\n\nAll requests to the SMASHSEND API require authentication. You'll need to include your API key in the Authorization header of all HTTP requests.\n\n```\n// Example of an authenticated request using JavaScript fetch\nconst apiKey = 'YOUR_API_KEY';\n\nconst response = await fetch('https://api.smashsend.com/v1/api-keys/check', {\n  headers: {\n    'Authorization': `Bearer ${apiKey}`,\n    'Content-Type': 'application/json'\n  }\n});\n\nconst data = await response.json();\nconsole.log(data);\n```\n\n## Step 2: Create a Contact\n\nLet's create a new contact through the API.\n\n```\n// Creating a contact with JavaScript\nconst apiKey = 'YOUR_API_KEY';\nconst contactData = {\n  properties: {\n    email: 'jane.doe@example.com',\n    firstName: 'Jane',\n    lastName: 'Doe',\n    company: 'Acme Inc'\n  }\n};\n\nconst response = await fetch('https://api.smashsend.com/v1/contacts', {\n  method: 'POST',\n  headers: {\n    'Authorization': `Bearer ${apiKey}`,\n    'Content-Type': 'application/json'\n  },\n  body: JSON.stringify(contactData)\n});\n\nconst result = await response.json();\nconsole.log(result);\n\n// Expected response:\n{\n  \"contact\": {\n    \"id\": \"ctc_B7OSYsnTUVwBPOGrgYTjvSGS\",\n    \"createdAt\": \"2025-06-04T05:26:05.593Z\",\n    \"updatedAt\": \"2025-06-04T05:26:05.593Z\",\n    \"properties\": {\n      \"email\": \"jane.doe@example.com\",\n      \"firstName\": \"Jane\",\n      \"lastName\": \"Doe\",\n      \"company\": \"Acme Inc\"\n    },\n    \"workspaceId\": \"wrk_ENGTK86JEXXckyDVJthKkPer\"\n  }\n}\n```\n\n## Step 3: Add Contact to a Campaign\n\nNow that we have created a contact, let's add them to an existing campaign.\n\n```\n// Adding a contact to a campaign\nconst apiKey = 'YOUR_API_KEY';\nconst campaignId = 'CAMPAIGN_ID';\nconst contactId = 'ctc_B7OSYsnTUVwBPOGrgYTjvSGS'; // The ID from the previous response\n\nconst response = await fetch(`https://api.smashsend.com/v1/campaigns/${campaignId}/contacts`, {\n  method: 'POST',\n  headers: {\n    'Authorization': `Bearer ${apiKey}`,\n    'Content-Type': 'application/json'\n  },\n  body: JSON.stringify({\n    contactId: contactId\n  })\n});\n\nconst result = await response.json();\nconsole.log(result);\n```\n\n## Step 4: Set Up a Webhook\n\nSetting up webhooks allows you to receive real-time notifications when events occur in your SMASHSEND account.\n\n```\n// Creating a webhook subscription\nconst apiKey = 'YOUR_API_KEY';\nconst webhookData = {\n  url: 'https://your-app.com/webhook-endpoint',\n  events: ['CONTACT_CREATED', 'CONTACT_UPDATED', 'CONTACT_DELETED'],\n  token: 'YOUR_WEBHOOK_SECRET' // Used to verify webhook payloads\n};\n\nconst response = await fetch('https://api.smashsend.com/v1/webhooks', {\n  method: 'POST',\n  headers: {\n    'Authorization': `Bearer ${apiKey}`,\n    'Content-Type': 'application/json'\n  },\n  body: JSON.stringify(webhookData)\n});\n\nconst result = await response.json();\nconsole.log(result);\n\n// Expected response:\n{\n  \"webhook\": {\n    \"id\": \"wh_123456789\",\n    \"url\": \"https://your-app.com/webhook-endpoint\",\n    \"events\": [\"CONTACT_CREATED\", \"CONTACT_UPDATED\", \"CONTACT_DELETED\"],\n    \"token\": \"wht_a1b2c3d4e5f6g7h8i9j0\",\n    \"createdAt\": \"2023-04-16T15:45:00Z\"\n  }\n}\n```\n\n## Step 5: Handling Webhook Events\n\nHere's an example of how to handle webhook events on your server (using Express.js):\n\n```\n// Setting up a webhook handler with Express.js\nconst express = require('express');\nconst crypto = require('crypto');\nconst app = express();\n\n// Middleware to parse JSON requests\napp.use(express.json());\n\n// Your webhook secret from Step 4\nconst WEBHOOK_SECRET = 'YOUR_WEBHOOK_SECRET';\n\n// Verify webhook signature\nfunction verifyWebhookSignature(req) {\n  const signature = req.headers['x-smashsend-signature'];\n  const payload = JSON.stringify(req.body);\n  \n  const hmac = crypto.createHmac('sha256', WEBHOOK_SECRET);\n  hmac.update(payload);\n  const calculatedSignature = hmac.digest('hex');\n  \n  return crypto.timingSafeEqual(\n    Buffer.from(signature),\n    Buffer.from(calculatedSignature)\n  );\n}\n\n// Webhook endpoint\napp.post('/webhook-endpoint', (req, res) => {\n  try {\n    // Verify the webhook signature\n    if (!verifyWebhookSignature(req)) {\n      return res.status(401).send('Invalid signature');\n    }\n    \n    // Process the webhook event\n    const event = req.body;\n    \n    console.log('Received webhook event:', event.event);\n    \n    switch (event.event) {\n      case 'CONTACT_CREATED':\n        // Handle new contact\n        console.log('New contact created:', event.data.contact.id);\n        break;\n      case 'CONTACT_UPDATED':\n        // Handle contact update\n        console.log('Contact updated:', event.data.contact.id);\n        break;\n      case 'CONTACT_DELETED':\n        // Handle contact deletion\n        console.log('Contact deleted:', event.data.contact.id);\n        break;\n      default:\n        console.log('Unhandled event type:', event.event);\n    }\n    \n    // Respond with a 200 OK\n    res.status(200).send('Webhook received');\n  } catch (error) {\n    console.error('Webhook error:', error);\n    res.status(500).send('Webhook processing error');\n  }\n});\n\napp.listen(3000, () => {\n  console.log('Webhook server running on port 3000');\n});\n```\n\n## Next Steps\n\nNow that you've learned the basics of integrating with the SMASHSEND API, here are some next steps:\n\n-   Explore the [Contacts API](https://smashsend.com/docs/api/contacts) for more advanced contact management features\n    \n-   Learn about [Contact properties API](https://smashsend.com/docs/api/contact-properties) for creating and managing campaigns\n    \n-   Learn about [Webhooks API](https://smashsend.com/docs/api/webhooks) for creating and managing campaigns\n    \n-   Learn about [API Keys API](https://smashsend.com/docs/api/api-keys) for creating and managing campaigns\n    \n-   Learn about [Users API](https://smashsend.com/docs/api/users) for creating and managing campaigns\n    \n-   Check out our [Postman Collection](https://smashsend.com/docs/api/postman) for ready-to-use API requests\n    \n-   Implement proper error handling and retry logic in your integration","storage":{"htmlKey":"stealpage/html/smashsend.com/pg_icmniccuptfb/run_helkrvqsig2u.html.gz","markdownKey":"stealpage/md/smashsend.com/pg_icmniccuptfb/run_helkrvqsig2u.md.gz"},"facets":null,"assets":[{"kind":"image","src_url":"https://smashsend.com/og/api_docs.jpg","r2_key":null,"alt":null,"caption":null,"width":null,"height":null,"is_hero":true,"zone":"main"},{"kind":"image","src_url":"https://smashsend.com/_next/static/media/smashsend_dark.da05b6ec.svg","r2_key":null,"alt":"SMASHSEND email marketing - The #1 Email Marketing Tool that turns emails into revenue","caption":null,"width":135,"height":30,"is_hero":false,"zone":"unknown"},{"kind":"image","src_url":"https://smashsend.com/dashboard/integrations/zapier_icon_filled.png","r2_key":null,"alt":"Zapier","caption":null,"width":20,"height":20,"is_hero":false,"zone":"nav"},{"kind":"image","src_url":"https://smashsend.com/dashboard/integrations/mailchimp_icon.png","r2_key":null,"alt":"Mailchimp","caption":null,"width":20,"height":20,"is_hero":false,"zone":"nav"},{"kind":"image","src_url":"https://smashsend.com/dashboard/integrations/webhooks_icon_gradient.png","r2_key":null,"alt":"Webhooks","caption":null,"width":20,"height":20,"is_hero":false,"zone":"nav"},{"kind":"image","src_url":"https://smashsend.com/dashboard/integrations/events.png","r2_key":null,"alt":"Events API","caption":null,"width":20,"height":20,"is_hero":false,"zone":"nav"},{"kind":"image","src_url":"https://smashsend.com/_next/image?q=75&url=%2Favatar-profile.png&w=3840","r2_key":null,"alt":"Jorge Ferreiro","caption":null,"width":null,"height":null,"is_hero":false,"zone":"nav"},{"kind":"image","src_url":"https://smashsend.com/_next/image?url=%2Favatar-profile.png&w=3840&q=75","r2_key":null,"alt":"Jorge Ferreiro","caption":null,"width":null,"height":null,"is_hero":false,"zone":"nav"},{"kind":"image","src_url":"https://smashsend.com/_next/static/media/smashsend_light.be8a3849.svg","r2_key":null,"alt":"SMASHSEND email marketing - The #1 Email Marketing Tool that turns emails into revenue","caption":null,"width":171,"height":38,"is_hero":false,"zone":"footer"},{"kind":"image","src_url":"https://smashsend.com/marketing/legal/gdpr_compliance.png","r2_key":null,"alt":"SOC2","caption":null,"width":null,"height":50,"is_hero":false,"zone":"footer"}],"shots":[{"viewport":"mobile","width":390,"height":844,"r2_key":"stealpage/shots/smashsend.com/pg_icmniccuptfb/run_helkrvqsig2u-mobile.png","phash":"2684e220c8e0a886","visual_delta":0,"captured_at":"2026-09-27T04:09:29.950Z"},{"viewport":"desktop","width":1440,"height":900,"r2_key":"stealpage/shots/smashsend.com/pg_icmniccuptfb/run_helkrvqsig2u-desktop.png","phash":"8e606143406060f8","visual_delta":0,"captured_at":"2026-09-27T04:09:29.591Z"},{"viewport":"mobile","width":390,"height":844,"r2_key":"stealpage/shots/smashsend.com/pg_icmniccuptfb/run_edyhmhiomne0-mobile.png","phash":"2684e220c8e0a886","visual_delta":null,"captured_at":"2026-08-28T03:13:49.738Z"},{"viewport":"desktop","width":1440,"height":900,"r2_key":"stealpage/shots/smashsend.com/pg_icmniccuptfb/run_edyhmhiomne0-desktop.png","phash":"8e606143406060f8","visual_delta":null,"captured_at":"2026-08-28T03:13:48.877Z"}],"history":[{"id":"run_helkrvqsig2u","started_at":"2026-09-27T04:09:24.555Z","http_status":200,"fetcher":"direct","changed":false,"diff":{"added":0,"removed":19,"similarity":null},"word_count":663},{"id":"run_edyhmhiomne0","started_at":"2026-08-28T03:13:39.282Z","http_status":200,"fetcher":"direct","changed":false,"diff":null,"word_count":682}],"citedBy":[]}