Clerk Go SDK
The Clerk Go SDK is built on top of the Clerk Backend API.
Installation
If you're using Go Modules and have a go.mod
file in your project's root, you can import clerk-sdk-go
directly:
Alternatively, you can go get
the package explicitly:
Usage
For details on how to use this module, see the Go Documentation.
The Clerk Go SDK is organized using a resource-based structure similar to the Clerk Backend API. Each API supports specific operations, like Create or List. While operations for each resource vary, a similar pattern is applied throughout Clerk Go.
To execute API operations, you must configure Clerk Go with your Clerk Secret Key. To find your Clerk Secret Key:
- In the Clerk Dashboard, navigate to the API keys page.
- In the Secret Keys section, copy your Secret Key.
Depending on your use case, there are two ways to use the Clerk Go SDK: With or without a client.
For most use cases, the API without a client is a better choice. It requires a minimal setup and provides a more concise API for invoking operations.
However, if you need to operate on multiple Clerk instances from one application, or need more flexibility for tests and mocking, you can instantiate multiple API clients with different API keys.
The following examples demonstrate both approaches.
Usage without a client
If you only use one API key, you can import the packages required for the APIs you need. Then you can execute your desired request methods as functions, such as $resource$.Get()
or $resource$.Delete()
. The following example demonstrates this process:
Usage with a client
If you're working with multiple keys, it's recommended to use Clerk Go with a client. The API packages for each
resource export a Client
, which supports all the API's operations.
This way, you can create as many clients as needed, each with their own API key, as shown in the following example:
For more usage details, see the examples or the library's README file.
Feedback
Last updated on