Hi! Curious if anyone here knows how to create a s...
# ask-community
t
Hi! Curious if anyone here knows how to create a secret either with prefect cli or via the rest api?
c
Hey Trent! As of right now, the only way to create a secret is to create a "Secret Block" (which can be done using the API alone on the
/block_documents/
route, but it's a bit messy). We are planning to make secret management more transparent in the near future, so will most likely expose more straightforward APIs/CLIs for this
t
Thank you for the response. Glad to hear your thinking about it. It’s really the last part to completely automate deployment using private GH repositories. Any chance you have a simple example you can send my way?
c
It'll take me a bit to write a fully complete example, because you need to look up two IDs from the backend first; here's an example in Python code just in case it helps move the needle for you:
Copy code
from prefect.blocks.system import Secret

s = Secret(value="my-secret-value")
await s.save(name="my-test-secret")
^^^ if you're able to print the requests made under the hood there you can recreate the API call pattern; I won't be able to take it that far until this evening
t
Thank you 🙏