{
  "id": "BGcPUEnBH8Xb3T9O",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Send an SMS through the OVHcloud API",
  "tags": [],
  "nodes": [
    {
      "id": "006a9f8e-75cf-4799-844c-91ed193723e6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2800,
        1568
      ],
      "parameters": {
        "width": 480,
        "height": 672,
        "content": "## Send an SMS through the OVHcloud API\n\n### How it works\n\nThis workflow manually sends an SMS through the OVHcloud SMS API. It first defines the required OVH credentials, SMS service name, recipient, and message, then generates the signed OVH request and posts it to the API endpoint.\n\n### Setup steps\n\n- Add valid OVHcloud API values for APPLICATION_KEY, APPLICATION_SECRET, CONSUMER_KEY, and SMS_SERVICE_NAME in the credentials setup node.\n- Set the SMS receiver and message text in the payload node.\n- Verify that the signing code uses the correct OVH API region, endpoint, HTTP method, and timestamp requirements.\n- Run the workflow manually to send the SMS.\n\n### Customization\n\nChange the receiver and message fields to send different SMS content, or replace the manual trigger with another trigger to automate sending."
      },
      "typeVersion": 1
    },
    {
      "id": "4c11da6e-df0d-4ee5-87fe-17346c6a840f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3360,
        1600
      ],
      "parameters": {
        "color": 7,
        "width": 624,
        "height": 304,
        "content": "## Initialize SMS inputs\n\nStarts the workflow manually, then sets the OVH API credentials and the SMS service name along with the recipient and message payload."
      },
      "typeVersion": 1
    },
    {
      "id": "3f1a37a3-b4da-496b-a3a6-d35e770f30b6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4016,
        1568
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 320,
        "content": "## Sign and send request\n\nBuilds the signed OVH SMS API request with URL, headers, and JSON body, then sends it as an HTTP POST request to OVHcloud."
      },
      "typeVersion": 1
    },
    {
      "id": "9055102f-60d6-46ce-996d-f8ded4e43641",
      "name": "Manual Execution Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        3408,
        1728
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "38104c9a-573c-49f3-801a-c4a31cb49f09",
      "name": "Set OVH API Credentials",
      "type": "n8n-nodes-base.set",
      "position": [
        3616,
        1728
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a1111111-1111-1111-1111-111111111111",
              "name": "APPLICATION_KEY",
              "type": "string",
              "value": "<application_key_here>"
            },
            {
              "id": "a2222222-2222-2222-2222-222222222222",
              "name": "APPLICATION_SECRET",
              "type": "string",
              "value": "<application_secret_here>"
            },
            {
              "id": "a3333333-3333-3333-3333-333333333333",
              "name": "CONSUMER_KEY",
              "type": "string",
              "value": "<consumer_key_here>"
            },
            {
              "id": "a4444444-4444-4444-4444-444444444444",
              "name": "SMS_SERVICE_NAME",
              "type": "string",
              "value": "sms-xx00000-1"
            },
            {
              "id": "a5555555-5555-5555-5555-555555555555",
              "name": "SMS_SENDER",
              "type": "string",
              "value": "n8n"
            },
            {
              "id": "a6666666-6666-6666-6666-666666666666",
              "name": "OVH_REGION",
              "type": "string",
              "value": "eu"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "91f56be3-ba49-4973-81dd-c998d4da56cd",
      "name": "Prepare SMS Payload",
      "type": "n8n-nodes-base.set",
      "position": [
        3840,
        1728
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b1111111-1111-1111-1111-111111111111",
              "name": "receiver",
              "type": "string",
              "value": "+1234567890"
            },
            {
              "id": "b2222222-2222-2222-2222-222222222222",
              "name": "message",
              "type": "string",
              "value": "Hello from n8n via OVHcloud!"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c5efb83a-7d7e-496f-bf32-902ebafd9bfa",
      "name": "Build OVH SMS API Request",
      "type": "n8n-nodes-base.code",
      "position": [
        4064,
        1728
      ],
      "parameters": {
        "jsCode": "// Build the OVH SMS API call (URL + signed headers + JSON body).\n// OVH signature scheme:\n//   X-Ovh-Signature = '$1$' + sha1(AS + '+' + CK + '+' + METHOD + '+' + URL + '+' + BODY + '+' + TIMESTAMP)\n// The timestamp uses local epoch seconds (close enough to OVH server time for most setups).\n// If you get INVALID_SIGNATURE errors, replace it by a GET /auth/time call.\n\nconst crypto = require('crypto');\nconst creds = $('Set OVH API Credentials').item.json;\nconst payload = $('Prepare SMS Payload').item.json;\n\nconst AK = creds.APPLICATION_KEY;\nconst AS = creds.APPLICATION_SECRET;\nconst CK = creds.CONSUMER_KEY;\nconst service = creds.SMS_SERVICE_NAME;\nconst sender = creds.SMS_SENDER || 'n8n';\nconst host = (creds.OVH_REGION === 'ca') ? 'https://ca.api.ovh.com/1.0' : 'https://eu.api.ovh.com/1.0';\n\nif (!AK || !AS || !CK || !service) {\n  throw new Error('Missing OVH credentials (APPLICATION_KEY / APPLICATION_SECRET / CONSUMER_KEY / SMS_SERVICE_NAME).');\n}\n\nconst url = `${host}/sms/${service}/jobs`;\nconst body = {\n  message: payload.message,\n  receivers: [payload.receiver],\n  sender: sender,\n  senderForResponse: false,\n  charset: 'UTF-8',\n  class: 'phoneDisplay',\n  noStopClause: true\n};\nconst bodyString = JSON.stringify(body);\nconst timestamp = Math.floor(Date.now() / 1000);\nconst toSign = [AS, CK, 'POST', url, bodyString, timestamp].join('+');\nconst signature = '$1$' + crypto.createHash('sha1').update(toSign).digest('hex');\n\nreturn [{\n  json: {\n    url,\n    body,\n    headers: {\n      'X-Ovh-Application': AK,\n      'X-Ovh-Consumer': CK,\n      'X-Ovh-Timestamp': timestamp.toString(),\n      'X-Ovh-Signature': signature,\n      'Content-Type': 'application/json'\n    }\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "26c66597-2789-40b0-9049-9ffa6ad6e49d",
      "name": "Post to OVH SMS API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4288,
        1728
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ $json.body }}",
        "sendBody": true,
        "jsonHeaders": "={{ JSON.stringify($json.headers) }}",
        "sendHeaders": true,
        "specifyBody": "json",
        "specifyHeaders": "json"
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "c118482a-8e9f-4f21-b4f0-364946ee1828",
  "nodeGroups": [],
  "connections": {
    "Prepare SMS Payload": {
      "main": [
        [
          {
            "node": "Build OVH SMS API Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set OVH API Credentials": {
      "main": [
        [
          {
            "node": "Prepare SMS Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Execution Trigger": {
      "main": [
        [
          {
            "node": "Set OVH API Credentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build OVH SMS API Request": {
      "main": [
        [
          {
            "node": "Post to OVH SMS API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}