Auth0 Home Blog Docs

Is there any way to add scopes programmatically without totally replacing them?

Using the Auth0 Management API extension - this code works but it totally replaces the existing scopes on the machine to machine api.

I want to add more scopes on the fly without having to do a pull everything add to the list and then replace it all.

C# using RestSharp example -

        var remoteClient = new RestClient(baseUrl);

        var remoteRequest = new RestRequest(Method.PATCH);

        remoteRequest.AddHeader("cache-control", "no-cache");
        remoteRequest.AddHeader("authorization", $"Bearer {MGMT_API_ACCESS_TOKEN}");
        remoteRequest.AddHeader("content-type", "application/json");
        remoteRequest.AddParameter("application/json", "{ "
          + "\"scopes\": [ "
          + "{ \"value\": \"create:library\", \"description\": \"Create Libraries\" },"
          + "{ \"value\": \"create:book\", \"description\": \"Add Book to Library\" },"
          + "{ \"value\": \"read:library\", \"description\": \"Read Libraries\" },"
          + "{ \"value\": \"read:books\", \"description\": \"Read Books\" }"
          + " ] }",
            ParameterType.RequestBody);

        var response = remoteClient.Execute(remoteRequest);