- list - Get a list of machines for an instance
- create - Create a machine
- get - Retrieve a machine
- update - Update a machine
- delete - Delete a machine
- getSecretKey - Retrieve a machine secret key
- rotateSecretKey - Rotate a machine's secret key
- createScope - Create a machine scope
- deleteScope - Delete a machine scope
This request returns the list of machines for an instance. The machines are ordered by descending creation date (i.e. most recent machines will be returned first)
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.ListMachinesResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
ListMachinesResponse res = sdk.machines().list()
.limit(10L)
.offset(0L)
.orderBy("-created_at")
.call();
if (res.machineList().isPresent()) {
System.out.println(res.machineList().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
limit |
Optional<Long> | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset. |
offset |
Optional<Long> | ➖ | Skip the first offset results when paginating.Needs to be an integer greater or equal to zero. To be used in conjunction with limit. |
query |
Optional<String> | ➖ | Returns machines with ID or name that match the given query. Uses exact match for machine ID and partial match for name. |
orderBy |
Optional<String> | ➖ | Allows to return machines in a particular order. You can order the returned machines by their name or created_at.To specify the direction, use the + or - symbols prepended to the property to order by.For example, to return machines in descending order by created_at, use -created_at.If you don't use + or -, then + is implied.Defaults to -created_at. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ClerkErrors | 400, 401, 403, 422 | application/json |
| models/errors/SDKError | 4XX, 5XX | */* |
Creates a new machine.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.CreateMachineResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
CreateMachineResponse res = sdk.machines().create()
.call();
if (res.machineCreated().isPresent()) {
System.out.println(res.machineCreated().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
request |
CreateMachineRequestBody | ✔️ | The request object to use for the request. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ClerkErrors | 400, 401, 403, 422 | application/json |
| models/errors/SDKError | 4XX, 5XX | */* |
Returns the details of a machine.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetMachineResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
GetMachineResponse res = sdk.machines().get()
.machineId("<id>")
.call();
if (res.machine().isPresent()) {
System.out.println(res.machine().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
machineId |
String | ✔️ | The ID of the machine to retrieve |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ClerkErrors | 400, 401, 403, 404, 422 | application/json |
| models/errors/SDKError | 4XX, 5XX | */* |
Updates an existing machine. Only the provided fields will be updated.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UpdateMachineResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
UpdateMachineResponse res = sdk.machines().update()
.machineId("<id>")
.call();
if (res.machine().isPresent()) {
System.out.println(res.machine().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
machineId |
String | ✔️ | The ID of the machine to update |
requestBody |
Optional<UpdateMachineRequestBody> | ➖ | N/A |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ClerkErrors | 400, 401, 403, 404, 422 | application/json |
| models/errors/SDKError | 4XX, 5XX | */* |
Deletes a machine.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeleteMachineResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
DeleteMachineResponse res = sdk.machines().delete()
.machineId("<id>")
.call();
if (res.machineDeleted().isPresent()) {
System.out.println(res.machineDeleted().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
machineId |
String | ✔️ | The ID of the machine to delete |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ClerkErrors | 400, 401, 403, 404, 422 | application/json |
| models/errors/SDKError | 4XX, 5XX | */* |
Returns the secret key for a machine.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetMachineSecretKeyResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
GetMachineSecretKeyResponse res = sdk.machines().getSecretKey()
.machineId("<id>")
.call();
if (res.machineSecretKey().isPresent()) {
System.out.println(res.machineSecretKey().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
machineId |
String | ✔️ | The ID of the machine to retrieve the secret key for |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ClerkErrors | 400, 401, 403, 404 | application/json |
| models/errors/SDKError | 4XX, 5XX | */* |
Rotates the machine's secret key. When the secret key is rotated, make sure to update it in your machine/application. The previous secret key will remain valid for the duration specified by the previous_token_ttl parameter.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.RotateMachineSecretKeyRequestBody;
import com.clerk.backend_api.models.operations.RotateMachineSecretKeyResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
RotateMachineSecretKeyResponse res = sdk.machines().rotateSecretKey()
.machineId("<id>")
.requestBody(RotateMachineSecretKeyRequestBody.builder()
.previousTokenTtl(632625L)
.build())
.call();
if (res.machineSecretKey().isPresent()) {
System.out.println(res.machineSecretKey().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
machineId |
String | ✔️ | The ID of the machine to rotate the secret key for |
requestBody |
RotateMachineSecretKeyRequestBody | ✔️ | N/A |
RotateMachineSecretKeyResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ClerkErrors | 400, 401, 403, 404, 422 | application/json |
| models/errors/SDKError | 4XX, 5XX | */* |
Creates a new machine scope, allowing the specified machine to access another machine. Maximum of 150 scopes per machine.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.CreateMachineScopeResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
CreateMachineScopeResponse res = sdk.machines().createScope()
.machineId("<id>")
.call();
if (res.machineScope().isPresent()) {
System.out.println(res.machineScope().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
machineId |
String | ✔️ | The ID of the machine that will have access to another machine |
requestBody |
Optional<CreateMachineScopeRequestBody> | ➖ | N/A |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ClerkErrors | 400, 401, 403, 404, 409, 422 | application/json |
| models/errors/SDKError | 4XX, 5XX | */* |
Deletes a machine scope, removing access from one machine to another.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeleteMachineScopeResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
DeleteMachineScopeResponse res = sdk.machines().deleteScope()
.machineId("<id>")
.otherMachineId("<id>")
.call();
if (res.machineScopeDeleted().isPresent()) {
System.out.println(res.machineScopeDeleted().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
machineId |
String | ✔️ | The ID of the machine that has access to another machine |
otherMachineId |
String | ✔️ | The ID of the machine that is being accessed |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ClerkErrors | 400, 401, 403, 404, 422 | application/json |
| models/errors/SDKError | 4XX, 5XX | */* |