(Keys)
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.GetKeyRequest{
KeyID: "key_1234",
}
ctx := context.Background()
res, err := s.Keys.GetKey(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Key != nil {
// handle response
}
}
*operations.GetKeyResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.DeleteKeyRequestBody{
KeyID: "key_1234",
}
ctx := context.Background()
res, err := s.Keys.DeleteKey(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.DeleteKeyResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.CreateKeyRequestBody{
APIID: "api_123",
Name: unkeygo.String("my key"),
ExternalID: unkeygo.String("team_123"),
Meta: map[string]any{
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z",
},
Roles: []string{
"admin",
"finance",
},
Permissions: []string{
"domains.create_record",
"say_hello",
},
Expires: unkeygo.Int64(1623869797161),
Remaining: unkeygo.Int64(1000),
Refill: &operations.Refill{
Interval: operations.IntervalDaily,
Amount: 100,
},
Ratelimit: &operations.Ratelimit{
Type: operations.TypeFast.ToPointer(),
Limit: 10,
Duration: unkeygo.Int64(60000),
},
Enabled: unkeygo.Bool(false),
}
ctx := context.Background()
res, err := s.Keys.CreateKey(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.CreateKeyResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/components"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := components.V1KeysVerifyKeyRequest{
APIID: unkeygo.String("api_1234"),
Key: "sk_1234",
Ratelimits: []components.Ratelimits{
components.Ratelimits{
Name: "requests",
Limit: unkeygo.Int64(500),
Duration: unkeygo.Int64(3600000),
},
components.Ratelimits{
Name: "tokens",
Limit: unkeygo.Int64(20000),
Duration: unkeygo.Int64(86400000),
},
},
}
ctx := context.Background()
res, err := s.Keys.VerifyKey(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.V1KeysVerifyKeyResponse != nil {
// handle response
}
}
*operations.VerifyKeyResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.UpdateKeyRequestBody{
KeyID: "key_123",
Name: unkeygo.String("Customer X"),
OwnerID: unkeygo.String("user_123"),
Meta: map[string]any{
"roles": []any{
"admin",
"user",
},
"stripeCustomerId": "cus_1234",
},
Expires: unkeygo.Int64(0),
Ratelimit: &operations.UpdateKeyRatelimit{
Type: operations.UpdateKeyTypeFast.ToPointer(),
Limit: 10,
RefillRate: unkeygo.Int64(1),
RefillInterval: unkeygo.Int64(60),
},
Remaining: unkeygo.Int64(1000),
Refill: &operations.UpdateKeyRefill{
Interval: operations.UpdateKeyIntervalDaily,
Amount: 100,
},
Enabled: unkeygo.Bool(true),
Roles: []operations.Roles{
operations.Roles{
ID: unkeygo.String("perm_123"),
},
operations.Roles{
Name: unkeygo.String("dns.record.create"),
},
operations.Roles{
Name: unkeygo.String("dns.record.delete"),
Create: unkeygo.Bool(true),
},
},
Permissions: []operations.Permissions{
operations.Permissions{
ID: unkeygo.String("perm_123"),
},
operations.Permissions{
Name: unkeygo.String("dns.record.create"),
},
operations.Permissions{
Name: unkeygo.String("dns.record.delete"),
Create: unkeygo.Bool(true),
},
},
}
ctx := context.Background()
res, err := s.Keys.UpdateKey(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.UpdateKeyResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.UpdateRemainingRequestBody{
KeyID: "key_123",
Op: operations.OpSet,
Value: unkeygo.Int64(1),
}
ctx := context.Background()
res, err := s.Keys.UpdateRemaining(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.UpdateRemainingResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.GetVerificationsRequest{
KeyID: unkeygo.String("key_1234"),
OwnerID: unkeygo.String("chronark"),
Start: unkeygo.Int64(1620000000000),
End: unkeygo.Int64(1620000000000),
Granularity: operations.GranularityDay.ToPointer(),
}
ctx := context.Background()
res, err := s.Keys.GetVerifications(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.GetVerificationsResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.AddPermissionsRequestBody{
KeyID: "<value>",
Permissions: []operations.AddPermissionsPermissions{
operations.AddPermissionsPermissions{},
},
}
ctx := context.Background()
res, err := s.Keys.AddPermissions(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ResponseBodies != nil {
// handle response
}
}
*operations.AddPermissionsResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.RemovePermissionsRequestBody{
KeyID: "<value>",
Permissions: []operations.RemovePermissionsPermissions{
operations.RemovePermissionsPermissions{
ID: unkeygo.String("perm_123"),
},
operations.RemovePermissionsPermissions{
Name: unkeygo.String("dns.record.create"),
},
},
}
ctx := context.Background()
res, err := s.Keys.RemovePermissions(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.RemovePermissionsResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.SetPermissionsRequestBody{
KeyID: "<value>",
Permissions: []operations.SetPermissionsPermissions{
operations.SetPermissionsPermissions{
ID: unkeygo.String("perm_123"),
},
operations.SetPermissionsPermissions{
Name: unkeygo.String("dns.record.create"),
},
operations.SetPermissionsPermissions{
Name: unkeygo.String("dns.record.delete"),
Create: unkeygo.Bool(true),
},
},
}
ctx := context.Background()
res, err := s.Keys.SetPermissions(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ResponseBodies != nil {
// handle response
}
}
*operations.SetPermissionsResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.AddRolesRequestBody{
KeyID: "<value>",
Roles: []operations.AddRolesRoles{
operations.AddRolesRoles{
ID: unkeygo.String("role_123"),
},
operations.AddRolesRoles{
Name: unkeygo.String("dns.record.create"),
},
operations.AddRolesRoles{
Name: unkeygo.String("dns.record.delete"),
Create: unkeygo.Bool(true),
},
},
}
ctx := context.Background()
res, err := s.Keys.AddRoles(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ResponseBodies != nil {
// handle response
}
}
*operations.AddRolesResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.RemoveRolesRequestBody{
KeyID: "<value>",
Roles: []operations.RemoveRolesRoles{
operations.RemoveRolesRoles{
ID: unkeygo.String("role_123"),
},
operations.RemoveRolesRoles{
Name: unkeygo.String("dns.record.create"),
},
},
}
ctx := context.Background()
res, err := s.Keys.RemoveRoles(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.RemoveRolesResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |
package main
import(
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"context"
"log"
)
func main() {
s := unkeygo.New(
unkeygo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := operations.SetRolesRequestBody{
KeyID: "<value>",
Roles: []operations.SetRolesRoles{
operations.SetRolesRoles{
ID: unkeygo.String("role_123"),
},
operations.SetRolesRoles{
Name: unkeygo.String("dns.record.create"),
},
operations.SetRolesRoles{
Name: unkeygo.String("dns.record.delete"),
Create: unkeygo.Bool(true),
},
},
}
ctx := context.Background()
res, err := s.Keys.SetRoles(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ResponseBodies != nil {
// handle response
}
}
*operations.SetRolesResponse, error
Error Object |
Status Code |
Content Type |
sdkerrors.ErrBadRequest |
400 |
application/json |
sdkerrors.ErrUnauthorized |
401 |
application/json |
sdkerrors.ErrForbidden |
403 |
application/json |
sdkerrors.ErrNotFound |
404 |
application/json |
sdkerrors.ErrConflict |
409 |
application/json |
sdkerrors.ErrTooManyRequests |
429 |
application/json |
sdkerrors.ErrInternalServerError |
500 |
application/json |
sdkerrors.SDKError |
4xx-5xx |
/ |