(Keys)
package main
import(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.GetKey(ctx, operations.GetKeyRequest{
KeyID: "key_1234",
})
if err != nil {
log.Fatal(err)
}
if res.Key != nil {
// handle response
}
}
*operations.GetKeyResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.Whoami(ctx, operations.WhoamiRequestBody{
Key: "sk_123",
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.WhoamiResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.DeleteKey(ctx, operations.DeleteKeyRequestBody{
KeyID: "key_1234",
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.DeleteKeyResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.CreateKey(ctx, 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.IntervalMonthly,
Amount: 100,
RefillDay: unkeygo.Float64(15),
},
Ratelimit: &operations.Ratelimit{
Limit: 10,
Duration: unkeygo.Int64(60000),
},
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.CreateKeyResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.VerifyKey(ctx, components.V1KeysVerifyKeyRequest{
APIID: unkeygo.String("api_1234"),
Key: "sk_1234",
Tags: []string{
"path=/v1/users/123",
"region=us-east-1",
},
Ratelimits: []components.Ratelimits{
components.Ratelimits{
Name: "tokens",
Limit: unkeygo.Int64(500),
Duration: unkeygo.Int64(3600000),
},
components.Ratelimits{
Name: "tokens",
Limit: unkeygo.Int64(20000),
Duration: unkeygo.Int64(86400000),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.V1KeysVerifyKeyResponse != nil {
// handle response
}
}
*operations.VerifyKeyResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.UpdateKey(ctx, operations.UpdateKeyRequestBody{
KeyID: "key_123",
Name: unkeygo.String("Customer X"),
ExternalID: 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),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.UpdateKeyResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.UpdateRemaining(ctx, operations.UpdateRemainingRequestBody{
KeyID: "key_123",
Op: operations.OpSet,
Value: unkeygo.Int64(1),
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.UpdateRemainingResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.GetVerifications(ctx, operations.KeysGetVerificationsRequest{
KeyID: unkeygo.String("key_1234"),
OwnerID: unkeygo.String("chronark"),
Start: unkeygo.Int64(1620000000000),
End: unkeygo.Int64(1620000000000),
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.KeysGetVerificationsResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.AddPermissions(ctx, operations.AddPermissionsRequestBody{
KeyID: "<id>",
Permissions: []operations.AddPermissionsPermissions{
operations.AddPermissionsPermissions{},
operations.AddPermissionsPermissions{},
operations.AddPermissionsPermissions{},
},
})
if err != nil {
log.Fatal(err)
}
if res.ResponseBodies != nil {
// handle response
}
}
*operations.AddPermissionsResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.RemovePermissions(ctx, operations.RemovePermissionsRequestBody{
KeyID: "<id>",
Permissions: []operations.RemovePermissionsPermissions{
operations.RemovePermissionsPermissions{
ID: unkeygo.String("perm_123"),
},
operations.RemovePermissionsPermissions{
Name: unkeygo.String("dns.record.create"),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.RemovePermissionsResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.SetPermissions(ctx, operations.SetPermissionsRequestBody{
KeyID: "<id>",
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),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ResponseBodies != nil {
// handle response
}
}
*operations.SetPermissionsResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.AddRoles(ctx, operations.AddRolesRequestBody{
KeyID: "<id>",
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),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ResponseBodies != nil {
// handle response
}
}
*operations.AddRolesResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.RemoveRoles(ctx, operations.RemoveRolesRequestBody{
KeyID: "<id>",
Roles: []operations.RemoveRolesRoles{
operations.RemoveRolesRoles{
ID: unkeygo.String("role_123"),
},
operations.RemoveRolesRoles{
Name: unkeygo.String("dns.record.create"),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
*operations.RemoveRolesResponse, error
Error Type |
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(
"context"
unkeygo "github.com/unkeyed/unkey-go"
"github.com/unkeyed/unkey-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := unkeygo.New(
unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
)
res, err := s.Keys.SetRoles(ctx, operations.SetRolesRequestBody{
KeyID: "<id>",
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),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ResponseBodies != nil {
// handle response
}
}
*operations.SetRolesResponse, error
Error Type |
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 |
*/* |