Use API to add custom catalog

Does anybody know if it is possible to add a custom catalog using Rancher’s API? I currently have scripts that use the API to create and configure a local Rancher instance with API Tokens and registries (DockerHub and Artifactory). I would also like to add in our custom Rancher Catalog.



The UI is entirely driven by the API. The catalog list is a setting with a comma-separated list of key/value (name=url) pairs.

You can GET the current value: GET /v1/settings/catalog.url

And then update the list with a new value: PUT /v1/settings/catalog.url {value: 'name1=url1, name2=url2'}

1 Like

I tried your suggestion using the following request I generated thru the API Browser but I got a “Method not allowed” error.

curl -u “D58E321A5A05680BF71C:WdnmhXsj3MaqtY7T6YFpCY2TYeAvYk3fHPSLeCMf”
-H ‘Accept: application/json’
-H ‘Content-Type: application/json’
-d ‘{“activeValue”:“library=, community=”, “id”:“1as!catalog.url”, “name”:“catalog.url”, “source”:“Default Environment Variables”, “value”:“library=, community=”}’!catalog.url


{“id”:“0884ac22-ad11-404a-a581-2a444ff81e44”,“type”:“error”,“links”:{},“actions”:{},“status”:405,“code”:“Method not allowed”,“message”:“Method not allowed”,“detail”:null}{“id”:“91437d43-1bb5-438a-955c-c580b2cdc394”,“type”:“error”,“links”:{},“actions”:{},“status”:405,“code”:“Method not allowed”,“message”:“Method not allowed”,“detail”:null}

It seems the API token I’m using for default environment does not work with settings. I have not yet enabled any authentication. How can I generate a key pair that will work against /v1/activesettings?

Figured it out looking from: forum post 1 and forum post 2

Basically need to first create an admin key with something like:

curl -X POST
-H ‘Accept: application/json’
-H ‘Content-Type: application/json’
-d ‘{“accountId”:“1a1”, “description”:“Scripting administration account”, “name”:“admin”, “publicValue”:“script”}’

Wait till it becomes active and then add the catalog with something like:

curl -u “admin:script”
-H ‘Accept: application/json’
-H ‘Content-Type: application/json’
-d ‘{“activeValue”:“library=, community=”, “id”:“1as!catalog.url”, “name”:“catalog.url”, “source”:“Default Environment Variables”, “value”:“library=, community=”, newXXX=https://XXXXX/XXXXX.git}’!catalog.url


With access control off you don’t need to send authentication at all, but settings are global so an environment-specific apikey doesn’t have access to change them.

1 Like

I was facing a similar problem and came across your solution and it did solve my problem. However, this only creates the catalog from the Main line of the git path. Is there a way to link a specific Branch?

Thank you in advance.

There’s a newer format as JSON which has a field for branch. If you setup what you want in the UI you can just GET /v2-beta/settings/catalog.url to see the right value.