{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Call Template via HTTP","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"call-template-via-http","__idx":0},"children":["Call Template via HTTP"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"1-get-authorization-oauth2-token","__idx":1},"children":["1. Get Authorization (OAuth2 Token)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Before calling any functional APIs, you must exchange your credentials for a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JWT Access Token"]},"."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Endpoint:"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST https://api.morelogin.com/oauth2/token"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Official Docs:"]}," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://guide.morelogin.com/api-reference/open-api/open-api/authorization/paths/~1oauth2~1token/post"},"children":["Authorization Path"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"request-curl","__idx":2},"children":["Request (cURL)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.morelogin.com/oauth2/token \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"client_id\": 1672940217990530,\n    \"client_secret\": \"your_client_secret\",\n    \"grant_type\": \"client_credentials\"\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"response-example","__idx":3},"children":["Response Example"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"code\": 0,\n    \"data\": {\n        \"access_token\": \"eyJhbGciOiJIUzI1NiIsIn...\",\n        \"token_type\": \"Bearer\",\n        \"expires_in\": 3600\n    }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"2-execute-cloud-phone-template","__idx":4},"children":["2. Execute Cloud Phone Template"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the access_token obtained from Step 1 to trigger a specific RPA template."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Endpoint:"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST https://api.morelogin.com/cloudphone/rpa/onceTask/save"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Official Docs:"]}," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://guide.morelogin.com/api-reference/open-api/open-api/cloud-phoneschedules-management/paths/~1cloudphone~1rpa~1oncetask~1save/post"},"children":["Execute Schedule Path"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"request-curl-1","__idx":5},"children":["Request (cURL)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.morelogin.com/cloudphone/rpa/onceTask/save \\\n  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"cloudPhoneId\": 16783319661123,\n    \"scheduleName\": \"test_automation\",\n    \"templateId\": 1678347487160256,\n    \"templateParameter\": \"{\\\"Video Caption\\\": \\\"Hello World\\\", \\\"AI Label\\\": true}\",\n    \"description\": \"schedule description\"\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"3-parameter-breakdown","__idx":6},"children":["3. Parameter Breakdown"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"how-to-get-ids","__idx":7},"children":["How to get IDs?"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Authorization:"]}," Obtained via the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/oauth2/token"]}," endpoint."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["cloudPhoneId:"]}," Found in the MoreLogin Cloud Phone dashboard (numeric ID)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["templateId:"]}," Found in the Automation Template market or personal template list."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"understanding-templateparameter","__idx":8},"children":["Understanding templateParameter"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This is a stringified JSON object. You must define the keys based on the template's requirements and then escape them as a string."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Template Definition Example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"Video Caption\": \"string\",\n    \"AI Label\": \"boolean\",\n    \"Product Id\": \"number\",\n    \"Get Leads\": \"boolean\",\n    \"Comment\": \"string\"\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["How to map it in your request:"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To pass values for the above definition, your templateParameter value should look like this:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"templateParameter\": \"{\\\"Video Caption\\\": \\\"My Title\\\", \\\"AI Label\\\": true, \\\"Product Id\\\": 12345}\"\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"4-error-handling","__idx":9},"children":["4. Error Handling"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Status"},"children":["Status"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Possible Reason"},"children":["Possible Reason"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["401 Unauthorized"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Token expired or invalid client credentials."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["400 Bad Request"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Invalid cloudPhoneId or malformed JSON in templateParameter."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["404 Not Found"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The templateId does not exist."]}]}]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"python-quick-start","__idx":10},"children":["Python Quick Start"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\nimport json\n\ndef run_morelogin_task():\n    # 1. Auth\n    auth_res = requests.post(\n        \"https://api.morelogin.com/oauth2/token\",\n        json={\n            \"client_id\": 1672940217990530,\n            \"client_secret\": \"your_secret\",\n            \"grant_type\": \"client_credentials\"\n        }\n    )\n    token = auth_res.json()['data']['access_token']\n\n    # 2. Execute\n    task_payload = {\n        \"cloudPhoneId\": 16783319661123,\n        \"templateId\": 1678347487160256,\n        \"templateParameter\": json.dumps({\n            \"Video Caption\": \"My Post\",\n            \"AI Label\": True\n        })\n    }\n    \n    headers = {\"Authorization\": f\"Bearer {token}\"}\n    response = requests.post(\n        \"https://api.morelogin.com/cloudphone/rpa/onceTask/save\",\n        json=task_payload,\n        headers=headers\n    )\n    return response.json()\n\nprint(run_morelogin_task())\n","lang":"python"},"children":[]}]},"headings":[{"value":"Call Template via HTTP","id":"call-template-via-http","depth":1},{"value":"1. Get Authorization (OAuth2 Token)","id":"1-get-authorization-oauth2-token","depth":2},{"value":"Request (cURL)","id":"request-curl","depth":3},{"value":"Response Example","id":"response-example","depth":3},{"value":"2. Execute Cloud Phone Template","id":"2-execute-cloud-phone-template","depth":2},{"value":"Request (cURL)","id":"request-curl-1","depth":3},{"value":"3. Parameter Breakdown","id":"3-parameter-breakdown","depth":2},{"value":"How to get IDs?","id":"how-to-get-ids","depth":3},{"value":"Understanding templateParameter","id":"understanding-templateparameter","depth":3},{"value":"4. Error Handling","id":"4-error-handling","depth":2},{"value":"Python Quick Start","id":"python-quick-start","depth":2}],"frontmatter":{"seo":{"title":"Call Template via HTTP"}},"lastModified":"2026-05-21T03:58:08.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/rparobotic-process-automation/04-integration/call-template-via-http","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}