This might be a newbie question: Is there an API t...
# ory-network
b
This might be a newbie question: Is there an API to set/change the SMS configuration of a Network project to update the url where otp SMSes are sent?
m
Hello @best-daybreak-48618 no newbie question! Yes you can use the API but I would recommend to use the Ory CLI for that, it is a bit easier to use. This would be an example command to change the config through the Ory CLI:
Copy code
ory patch identity-config --project ${project_id} \
  --add '/courier/channels=[{"id":"sms","request_config":{"method":"PUT","body":"<base64://ZnVuY3Rpb24oY3R4KSB7DQpjdHg6IGN0eCwNCn0>=","url":"<https://your-sms-provider.com/api/send>"}}]'
You can also get and update the entire Ory Identities config:
Copy code
ory update identity-config --project <project-id> --workspace <workspace-id> --file config.yaml
You can also use the "projects" API directly, see an example here. https://www.ory.sh/docs/guides/manage-project-via-api#update-an-ory-network-project-configuration
b
Thanks Vincent, I was looking for an API so I could use it in my integration tests, I'll check out the projects API
Hi Vincent, I tried the below API request, and while it seems to execute successfully it does't actually change the value of the sms url. Can you tell what might be wrong? Thanks.
Copy code
curl --location --request PATCH "<https://api.console.ory.sh/projects/><PROJECT_ID>" \
-H "Authorization: Bearer <WORKSPACE_API_KEY>" \
-H "Content-Type: application/json" \
-d '[
  {
    "op": "replace",
    "path": "/courier/channels",
    "value": { 
      "id":"sms",
      "request_config":{
         "auth":{
            "config":{
               "password":"",
               "user":""
            },
            "type":"basic_auth"
         },
         "body":"<unchanged Jsonnet url>",
         "headers":{

         },
         "method":"POST",
         "url":"<https://webhook.site/>"
      },
      "type":"http"
    } 
  }
]' | jq
FYI, the CLI works as expected, but I need the API to work so I can set the sms url dynamically baed on the environment I am running the tests from. This is the CLI that I a ran:
Copy code
ory patch identity-config --project <PROJECT_ID> \
  --replace '/courier/channels=[{"id":"sms","request_config":{"auth":{"config":{ "password":"","user":""},"type":"basic_auth"},"body":"<https://storage.googleapis.com/bac-gcs-production/68dbe76c2f176b9bb0e10953d13c9d3fbf8c2baf240ee10304a9e84b78ade91c89bf7b110c88e9f06f682ff46ee9e7d70289a0a095597d8723ffbccc97838392.jsonnet>","headers":{},"method":"POST","url":"<https://webhook.site/94843be7-0c06-40e6-a2c0->"},"type":"http"}]'
I figured it out, I needed to correct the path. Thanks.