Manage your fleet with Viam's fleet management API

The fleet management API allows you to manage your machine fleet with code instead of with the graphical interface of the Viam app. With it you can

  • create and manage organizations, locations, and individual machines
  • manage permissions and authorization
  • create and manage fragments

The fleet management API supports the following methods:

Method NameDescription
GetUserIDByEmailGet the ID of a user by email.
CreateOrganizationCreate an organization.
ListOrganizationsList the organizations the user is an authorized user of.
GetOrganizationsWithAccessToLocationGet all organizations that have access to a location.
ListOrganizationsByUserList the organizations a user belongs to.
GetOrganizationRetrieve the organization object for the requested organization containing the organization’s ID, name, public namespace, and more.
GetOrganizationNamespaceAvailabilityCheck the availability of an organization namespace.
UpdateOrganizationUpdates organization details.
DeleteOrganizationDelete an organization.
ListOrganizationMembersList the members and invites of the organization that you are currently authenticated to.
CreateOrganizationInviteCreate an organization invite and send it by email.
UpdateOrganizationInviteAuthorizationsUpdate (add or remove) the authorizations attached to an organization invite that has already been created.
DeleteOrganizationMemberRemove a member from the organization you are currently authenticated to.
DeleteOrganizationInviteDelete a pending organization invite to the organization you are currently authenticated to.
ResendOrganizationInviteResend a pending organization invite email.
GetOrganizationMetadataGets the user-defined metadata for an organization.
UpdateOrganizationMetadataUpdates the user-defined metadata for an organization.
CreateLocationCreate and name a location under the organization you are currently authenticated to.
GetLocationGet a location by its location ID.
UpdateLocationChange the name of a location and/or assign a parent location to a location.
DeleteLocationDelete a location.
ListLocationsGet a list of all locations under the organization you are currently authenticated to.
ShareLocationShare a location with an organization.
UnshareLocationStop sharing a location with an organization.
LocationAuthGet a location’s LocationAuth (location secret or secrets).
CreateLocationSecretCreate a new location secret.
DeleteLocationSecretDelete a location secret.
GetLocationMetadataGet the user-defined metadata for a location.
UpdateLocationMetadataUpdate the user-defined metadata for a location.
GetRobotGet a machine by its ID.
GetRobotAPIKeysGets the API keys for the machine.
GetRobotPartsGet a list of all the parts under a specific machine.
GetRobotPartGet a specific machine part.
GetRobotPartLogsGet the logs associated with a specific machine part.
TailRobotPartLogsGet an asynchronous iterator that receives live machine part logs.
GetRobotPartHistoryGet a list containing the history of a machine part.
UpdateRobotPartChange the name of and assign an optional new configuration to a machine part.
NewRobotPartCreate a new machine part.
DeleteRobotPartDelete the specified machine part.
MarkPartAsMainMark a machine part as the main part of a machine.
MarkPartForRestartMark a specified machine part for restart.
CreateRobotPartSecretCreate a machine part secret.
DeleteRobotPartSecretDelete a machine part secret.
ListRobotsGet a list of all machines in a specified location.
NewRobotCreate a new machine.
UpdateRobotChange the name of an existing machine.
DeleteRobotDelete a specified machine.
GetRobotMetadataGets the user-defined metadata for a machine.
GetRobotPartMetadataGets the user-defined metadata for a machine part.
UpdateRobotMetadataUpdates the user-defined metadata for a machine.
UpdateRobotPartMetadataUpdates the user-defined metadata for a machine part.
ListFragmentsGet a list of fragments in the organization you are currently authenticated to.
ListMachineFragmentsGet a list of top level and nested fragments for a machine, as well as additionally specified fragment IDs.
GetFragmentGet a fragment by ID.
CreateFragmentCreate a new private fragment.
UpdateFragmentUpdate a fragment name and its config and/or visibility.
DeleteFragmentDelete a fragment.
GetFragmentHistoryGet fragment history.
AddRoleAdd a role under the organization you are currently authenticated to.
RemoveRoleRemove a role under the organization you are currently authenticated to.
ChangeRoleChanges an existing role to a new role.
ListAuthorizationsList all authorizations (owners and operators) of a specific resource (or resources) within the organization you are currently authenticated to.
CheckPermissionsCheck if the organization, location, or robot your ViamClient is authenticated to is permitted to perform some action or set of actions on the resource you pass to the method.
GetRegistryItemGet registry item by ID.
CreateRegistryItemCreate a registry item.
UpdateRegistryItemUpdate a registry item.
ListRegistryItemsList the registry items in an organization.
DeleteRegistryItemDelete a registry item.
CreateModuleCreate a module under the organization you are currently authenticated to.
UpdateModuleUpdate the documentation URL, description, models, entrypoint, and/or the visibility of a module.
UploadModuleFileUpload a module file.
GetModuleGet a module by its ID.
ListModulesList the modules under the organization you are currently authenticated to.
CreateKeyCreate a new API key.
DeleteKeyDelete an API key.
RotateKeyRotate an API key.
ListKeysList all keys for the organization that you are currently authenticated to.
CreateKeyFromExistingKeyAuthorizationsCreate a new API key with an existing key’s authorizations.
GetAppContentRetrieve the app content for an organization.

Establish a connection

To use the Viam fleet management API, you first need to instantiate a ViamClient and then instantiate an AppClient.

You will also need an API key and API key ID to authenticate your session. To get an API key (and corresponding ID), you have two options:

The following example instantiates a ViamClient, authenticating with an API key, and then instantiates an AppClient:

import asyncio

from viam.rpc.dial import DialOptions, Credentials
from viam.app.viam_client import ViamClient


async def connect() -> ViamClient:
    dial_options = DialOptions(
      credentials=Credentials(
        type="api-key",
        # Replace "<API-KEY>" (including brackets) with your API key
        payload='<API-KEY>',
      ),
      # Replace "<API-KEY-ID>" (including brackets) with your API key
      # ID
      auth_entity='<API-KEY-ID>'
    )
    return await ViamClient.create_from_dial_options(dial_options)


async def main():

    # Make a ViamClient
    viam_client = await connect()
    # Instantiate an AppClient called "cloud"
    # to run fleet management API methods on
    cloud = viam_client.app_client

    viam_client.close()

if __name__ == '__main__':
    asyncio.run(main())
package main

import (
    "context"
    "log"

    "go.viam.com/rdk/app"
    "go.viam.com/rdk/logging"
    "go.viam.com/utils"
)

func main() {
    logger := logging.NewLogger("fleet-management")
    
    // Replace "<API-KEY-ID>" (including brackets) with your API key ID
    apiKeyID := "<API-KEY-ID>"
    // Replace "<API-KEY>" (including brackets) with your API key
    apiKey := "<API-KEY>"
    
    client, err := app.NewAppClient(context.Background(), app.Config{
        BaseURL: "https://app.viam.com:443",
        Auth: utils.Credentials{
            Type:    utils.CredentialsTypeAPIKey,
            Payload: apiKey,
        },
        AuthEntity: &apiKeyID,
        Logger:     logger,
    })
    if err != nil {
        log.Fatalf("Failed to create app client: %v", err)
    }
    defer client.Close()
    
    // Use the client to make fleet management API calls
    // Example: List organizations
    ctx := context.Background()
    orgs, err := client.ListOrganizations(ctx)
    if err != nil {
        log.Fatalf("Failed to list organizations: %v", err)
    }
    
    for _, org := range orgs {
        log.Printf("Organization: %s (ID: %s)", org.Name, org.Id)
    }
}
async function connect(): Promise<VIAM.ViamClient> {
  // Replace "<API-KEY-ID>" (including brackets) with your machine's
  const API_KEY_ID = "<API-KEY-ID>";
  // Replace "<API-KEY>" (including brackets) with your machine's API key
  const API_KEY = "<API-KEY>";
  const opts: VIAM.ViamClientOptions = {
    serviceHost: "https://app.viam.com:443",
    credentials: {
      type: "api-key",
      authEntity: API_KEY_ID,
      payload: API_KEY,
    },
  };

  const client = await VIAM.createViamClient(opts);
  return client;
}

const viamClient = await connect();
const appClient = appClient.appClient;

Once you have instantiated an AppClient, you can run the following API methods against the AppClient object (named fleet in the examples).

To instantiate an `AppClient` from inside a module, you must authenticate using API keys. You can use the module environment variables `VIAM_API_KEY` and `VIAM_API_KEY_ID` to access credentials.

API

GetUserIDByEmail

Get the ID of a user by email.

Parameters:

  • email (str) (required): The email of the user.

Returns:

  • (str): The ID of the user.

Example:

id = await cloud.get_user_id_by_email("youremail@email.com")

For more information, see the Python SDK Docs.

Parameters:

  • email (string) (required): The email of the user.

Returns:

  • (string): The ID of the user.
  • (error): An error, if one occurred.

Example:

userID, err := client.GetUserIDByEmail(ctx, "youremail@email.com")
if err != nil {
    log.Fatalf("Failed to get user ID: %v", err)
}
fmt.Printf("User ID: %s\n", userID)

For more information, see the Go SDK Docs.

Parameters:

  • email (string) (required): The email address of the user.

Returns:

  • (Promise): The user’s ID.

Example:

// This method is used internally only. To obtain a user's ID, use the listOrganizationsByUser method.
const members = await appClient.listOrganizationMembers(
  '<YOUR-ORGANIZATION-ID>'
);

For more information, see the TypeScript SDK Docs.

CreateOrganization

Create an organization.

Parameters:

  • name (str) (required): The name of the organization.

Returns:

Example:

organization = await cloud.create_organization("name")

For more information, see the Python SDK Docs.

Parameters:

  • name (string) (required): The name of the organization.

Returns:

  • (*app.Organization): The created organization.
  • (error): An error, if one occurred.

Example:

organization, err := client.CreateOrganization(ctx, "name")
if err != nil {
    log.Fatalf("Failed to create organization: %v", err)
}
fmt.Printf("Created organization: %s\n", organization.Name)

For more information, see the Go SDK Docs.

Parameters:

  • name (string) (required): The name of the new organization.

Returns:

For more information, see the TypeScript SDK Docs.

ListOrganizations

List the organizations the user is an authorized user of.

Parameters:

  • None.

Returns:

Example:

org_list = await cloud.list_organizations()

For more information, see the Python SDK Docs.

Parameters:

  • None.

Returns:

  • ([]*app.Organization): The list of organizations.
  • (error): An error, if one occurred.

Example:

orgList, err := client.ListOrganizations(ctx)
if err != nil {
    log.Fatalf("Failed to list organizations: %v", err)
}
for _, org := range orgList {
    fmt.Printf("Organization: %s (ID: %s)\n", org.Name, org.Id)
}

For more information, see the Go SDK Docs.

Parameters:

  • None.

Returns:

Example:

const organizations = await appClient.listOrganizations();

For more information, see the TypeScript SDK Docs.

GetOrganizationsWithAccessToLocation

Get all organizations that have access to a location.

Parameters:

  • location_id (str) (required): The ID of the location.

Returns:

Example:

org_list = await cloud.get_organizations_with_access_to_location("location-id")

For more information, see the Python SDK Docs.

Parameters:

  • locationID (string) (required): The ID of the location.

Returns:

  • ([]*app.OrganizationIdentity): The list of organizations.
  • (error): An error, if one occurred.

Example:

orgList, err := client.GetOrganizationsWithAccessToLocation(ctx, "location-id")
if err != nil {
    log.Fatalf("Failed to get organizations with access to location: %v", err)
}
for _, org := range orgList {
    fmt.Printf("Organization: %s\n", org.Name)
}

For more information, see the Go SDK Docs.

Parameters:

  • locationId (string) (required): The ID of the location to query.

Returns:

Example:

const organizations =
  await appClient.getOrganizationsWithAccessToLocation(
    '<YOUR-LOCATION-ID>'
  );

For more information, see the TypeScript SDK Docs.

ListOrganizationsByUser

List the organizations a user belongs to.

Parameters:

  • user_id (str) (required): The ID of the user. You can retrieve this with the get_user_id_by_email() method.

Returns:

Example:

org_list = await cloud.list_organizations_by_user("<YOUR-USER-ID>")

For more information, see the Python SDK Docs.

Parameters:

  • userID (string) (required): The ID of the user. You can retrieve this with the GetUserIDByEmail() method.

Returns:

  • ([]*app.OrgDetails): The list of organizations.
  • (error): An error, if one occurred.

Example:

orgList, err := client.ListOrganizationsByUser(ctx, "<YOUR-USER-ID>")
if err != nil {
    log.Fatalf("Failed to list organizations by user: %v", err)
}
for _, org := range orgList {
    fmt.Printf("Organization: %s\n", org.OrgName)
}

For more information, see the Go SDK Docs.

Parameters:

  • userId (string) (required): The ID of the user to query.

Returns:

  • (Promise<OrgDetails[]>): The list of locations the requested user has access to.

For more information, see the TypeScript SDK Docs.

GetOrganization

Retrieve the organization object for the requested organization containing the organization’s ID, name, public namespace, and more.

Parameters:

  • org_id (str) (required): The ID of the organization to query. You can retrieve this from the organization settings page.

Returns:

Raises:

  • (GRPCError): If the provided org_id is invalid, or not currently authed to.

Example:

org = await cloud.get_organization("<YOUR-ORG-ID>")

For more information, see the Python SDK Docs.

Parameters:

  • orgID (string) (required): The ID of the organization to query. You can retrieve this from the organization settings page.

Returns:

  • (*app.Organization): The requested organization.
  • (error): An error, if one occurred.

Example:

org, err := client.GetOrganization(ctx, "<YOUR-ORG-ID>")
if err != nil {
    log.Fatalf("Failed to get organization: %v", err)
}
fmt.Printf("Organization: %s\n", org.Name)

For more information, see the Go SDK Docs.

Parameters:

  • organizationId (string) (required): The ID of the organization.

Returns:

  • (Promise<undefined | Organization>): Details about the organization, if it exists.

Example:

const organization = await appClient.getOrganization(
  '<YOUR-ORGANIZATION-ID>'
);

For more information, see the TypeScript SDK Docs.

GetOrganizationNamespaceAvailability

Check the availability of an organization namespace.

Parameters:

  • public_namespace (str) (required): Organization namespace to check. Namespaces can only contain lowercase alphanumeric and dash characters.

Returns:

  • (bool): True if the provided namespace is available.

Raises:

  • (GRPCError): If an invalid namespace (for example, “”) is provided.

Example:

available = await cloud.get_organization_namespace_availability(
    public_namespace="my-cool-organization")

For more information, see the Python SDK Docs.

Parameters:

  • publicNamespace (string) (required): Organization namespace to check. Namespaces can only contain lowercase alphanumeric and dash characters.

Returns:

  • (bool): True if the provided namespace is available.
  • (error): An error, if one occurred.

Example:

available, err := client.GetOrganizationNamespaceAvailability(ctx, "my-cool-organization")
if err != nil {
    log.Fatalf("Failed to check namespace availability: %v", err)
}
fmt.Printf("Namespace available: %t\n", available)

For more information, see the Go SDK Docs.

Parameters:

  • namespace (string) (required): The namespace to query for availability.

Returns:

  • (Promise): A boolean indicating whether or not the namespace is available.

Example:

const isAvailable =
  await appClient.getOrganizationNamespaceAvailability('name');

For more information, see the TypeScript SDK Docs.

UpdateOrganization

Updates organization details.

Parameters:

  • org_id (str) (required): The ID of the organization to update.
  • name (str) (optional): If provided, updates the org’s name.
  • public_namespace (str) (optional): If provided, sets the org’s namespace if it hasn’t already been set.
  • region (str) (optional): If provided, updates the org’s region.
  • cid (str) (optional): If provided, update’s the org’s CRM ID.

Returns:

Raises:

  • (GRPCError): If the org’s namespace has already been set, or if the provided namespace is already taken.

Example:

organization = await cloud.update_organization(
    org_id="<YOUR-ORG-ID>",
    name="Artoo's Org",
    public_namespace="artoo"
)

For more information, see the Python SDK Docs.

Parameters:

  • orgID (string) (required): The ID of the organization to update.
  • name (*string) (optional): If provided, updates the org’s name.
  • publicNamespace (*string) (optional): If provided, sets the org’s namespace if it hasn’t already been set.
  • region (*string) (optional): If provided, updates the org’s region.
  • cid (*string) (optional): If provided, updates the org’s CRM ID.

Returns:

  • (*app.Organization): The updated organization.
  • (error): An error, if one occurred.

Example:

name := "Artoo's Org"
publicNamespace := "artoo"
organization, err := client.UpdateOrganization(ctx, "<YOUR-ORG-ID>", &name, &publicNamespace, nil, nil)
if err != nil {
    log.Fatalf("Failed to update organization: %v", err)
}
fmt.Printf("Updated organization: %s\n", organization.Name)

For more information, see the Go SDK Docs.

Parameters:

  • organizationId (string) (required): The id of the organization to update.
  • name (string) (optional): Optional name to update the organization with.
  • publicNamespace (string) (optional): Optional namespace to update the organization with.
  • region (string) (optional): Optional region to update the organization with.
  • cid (string) (optional): Optional CRM ID to update the organization with.

Returns:

  • (Promise<undefined | Organization>): The updated organization details.

Example:

const organization = await appClient.updateOrganization(
  '<YOUR-ORGANIZATION-ID>',
  'newName'
);

For more information, see the TypeScript SDK Docs.

DeleteOrganization

Delete an organization.

Parameters:

  • org_id (str) (required): The ID of the organization. You can obtain your organization ID from the Viam app’s organization settings page.

Returns:

  • None.

Example:

await cloud.delete_organization("<YOUR-ORG-ID>")

For more information, see the Python SDK Docs.

Parameters:

  • orgID (string) (required): The ID of the organization. You can obtain your organization ID from the Viam app’s organization settings page.

Returns:

  • (error): An error, if one occurred.

Example:

err := client.DeleteOrganization(ctx, "<YOUR-ORG-ID>")
if err != nil {
    log.Fatalf("Failed to delete organization: %v", err)
}

For more information, see the Go SDK Docs.

Parameters:

  • organizationId (string) (required): The id of the organization to delete.

Returns:

  • (Promise)

Example:

await appClient.deleteOrganization('<YOUR-ORGANIZATION-ID>');

For more information, see the TypeScript SDK Docs.

ListOrganizationMembers

List the members and invites of the organization that you are currently authenticated to.

Parameters:

  • org_id (str) (required): The ID of the organization to list members of. You can obtain your organization ID from the Viam app’s organization settings page.

Returns:

Example:

member_list, invite_list = await cloud.list_organization_members("<YOUR-ORG-ID>")

For more information, see the Python SDK Docs.

Parameters:

  • orgID (string) (required): The ID of the organization to list members of. You can obtain your organization ID from the Viam app’s organization settings page.

Returns:

  • ([]*app.OrganizationMember): The list of organization members.
  • ([]*app.OrganizationInvite): The list of organization invites.
  • (error): An error, if one occurred.

Example:

memberList, inviteList, err := client.ListOrganizationMembers(ctx, "<YOUR-ORG-ID>")
if err != nil {
    log.Fatalf("Failed to list organization members: %v", err)
}
fmt.Printf("Found %d members and %d invites\n", len(memberList), len(inviteList))

For more information, see the Go SDK Docs.

Parameters:

  • organizationId (string) (required): The id of the organization to query.

Returns:

Example:

const members = await appClient.listOrganizationMembers(
  '<YOUR-ORGANIZATION-ID>'
);

For more information, see the TypeScript SDK Docs.

CreateOrganizationInvite

Create an organization invite and send it by email.

Parameters:

  • org_id (str) (required): The ID of the organization to create an invite for. You can obtain your organization ID from the Viam app’s organization settings page.
  • email (str) (required): The email address to send the invite to.
  • authorizations (List[viam.proto.app.Authorization]) (optional): Specifications of the authorizations to include in the invite. If not provided, full owner permissions will be granted.
  • send_email_invite (bool) (required): Whether or not an email should be sent to the recipient of an invite. The user must accept the email to be added to the associated authorizations. When set to false, the user automatically receives the associated authorization on the next login of the user with the associated email address.

Returns:

Raises:

  • (GRPCError): if an invalid email is provided, or if the user is already a member of the org.

Example:

await cloud.create_organization_invite("<YOUR-ORG-ID>", "youremail@email.com")

For more information, see the Python SDK Docs.

Parameters:

  • orgID (string) (required): The ID of the organization to create an invite for. You can obtain your organization ID from the Viam app’s organization settings page.
  • email (string) (required): The email address to send the invite to.
  • authorizations ([]*app.Authorization) (optional): Specifications of the authorizations to include in the invite. If not provided, full owner permissions will be granted.
  • sendEmailInvite (*bool) (optional): Whether or not an email should be sent to the recipient of an invite. Defaults to true.

Returns:

  • (*app.OrganizationInvite): The organization invite.
  • (error): An error, if one occurred.

Example:

invite, err := client.CreateOrganizationInvite(ctx, "<YOUR-ORG-ID>", "youremail@email.com", nil, nil)
if err != nil {
    log.Fatalf("Failed to create organization invite: %v", err)
}
fmt.Printf("Created invite for: %s\n", invite.Email)

For more information, see the Go SDK Docs.

Parameters:

  • organizationId (string) (required): The id of the organization to create the invite for.
  • email (string) (required): The email address of the user to generate an invite for.
  • authorizations (Authorization) (required): The authorizations to associate with the new invite.
  • sendEmailInvite (boolean) (optional): Bool of whether to send an email invite (true) or automatically add a user. Defaults to true.

Returns:

Example:

const auth = new VIAM.appApi.Authorization({
  authorizationType: 'role',
  authorizationId: 'organization_operator',
  organizationId: '<YOUR-ORGANIZATION-ID>',
  resourceId: '<YOUR-RESOURCE-ID>', // The resource to grant access to
  resourceType: 'organization', // The type of resource to grant access to
  identityId: '<YOUR-USER-ID>', // The user id of the user to grant access to (optional)
  roleId: 'owner', // The role to grant access to
  identityType: 'user',
});

const invite = await appClient.createOrganizationInvite(
  '<YOUR-ORGANIZATION-ID>',
  'youremail@email.com',
  [auth]
);

For more information, see the TypeScript SDK Docs.

ListRobots

Get a list of all machines in a specified location.

Parameters:

  • location_id (str) (optional): ID of the location to retrieve the machines from. Defaults to the location ID provided at AppClient instantiation.

Returns:

Raises:

  • (GRPCError): If an invalid location ID is passed or one isn’t passed and there was no location ID provided at AppClient instantiation.

Example:

list_of_machines = await cloud.list_robots(location_id="123ab12345")

For more information, see the Python SDK Docs.

Parameters:

  • locationID (string) (required): ID of the location to retrieve the machines from.

Returns:

  • ([]*app.Robot): The list of robots.
  • (error): An error, if one occurred.

Example:

listOfMachines, err := client.ListRobots(ctx, "123ab12345")
if err != nil {
    log.Fatalf("Failed to list robots: %v", err)
}
for _, robot := range listOfMachines {
    fmt.Printf("Robot: %s (ID: %s)\n", robot.Name, robot.Id)
}

For more information, see the Go SDK Docs.

Parameters:

  • locId (string) (required): The ID of the location to list robots for.

Returns:

Example:

const robots = await appClient.listRobots('<YOUR-LOCATION-ID>');

For more information, see the TypeScript SDK Docs.

NewRobot

Create a new machine.

Parameters:

  • name (str) (required): Name of the new machine.
  • location_id (str) (optional): ID of the location under which to create the machine. Defaults to the current authorized location.

Returns:

  • (str): The new robot’s ID.

Raises:

  • (GRPCError): If an invalid location ID is passed or one isn’t passed and there was no location ID provided at AppClient instantiation.

Example:

new_machine_id = await cloud.new_robot(name="beepboop", location_id="my-location-id")

For more information, see the Python SDK Docs.

Parameters:

  • name (string) (required): Name of the new machine.
  • locationID (string) (required): ID of the location under which to create the machine.

Returns:

  • (string): The new robot’s ID.
  • (error): An error, if one occurred.

Example:

newMachineID, err := client.NewRobot(ctx, "beepboop", "my-location-id")
if err != nil {
    log.Fatalf("Failed to create new robot: %v", err)
}
fmt.Printf("Created new robot with ID: %s\n", newMachineID)

For more information, see the Go SDK Docs.

Parameters:

  • locId (string) (required): The ID of the location to create the robot in.
  • name (string) (required): The name of the new robot.

Returns:

  • (Promise): The new robot’s ID.

Example:

const robotId = await appClient.newRobot(
  '<YOUR-LOCATION-ID>',
  'newRobot'
);

For more information, see the TypeScript SDK Docs.

GetRobot

Get a machine by its ID.

Parameters:

  • robot_id (str) (required): ID of the machine to get. You can copy this value from the URL of the machine’s page.

Returns:

Raises:

  • (GRPCError): If an invalid machine ID is passed.

Example:

machine = await cloud.get_robot(robot_id="1a123456-x1yz-0ab0-a12xyzabc")

For more information, see the Python SDK Docs.

Parameters:

  • robotID (string) (required): ID of the machine to get. You can copy this value from the URL of the machine’s page.

Returns:

  • (*app.Robot): The machine.
  • (error): An error, if one occurred.

Example:

machine, err := client.GetRobot(ctx, "1a123456-x1yz-0ab0-a12xyzabc")
if err != nil {
    log.Fatalf("Failed to get robot: %v", err)
}
fmt.Printf("Robot: %s\n", machine.Name)

For more information, see the Go SDK Docs.

Parameters:

  • id (string) (required): The ID of the robot.

Returns:

Example:

const robot = await appClient.getRobot('<YOUR-ROBOT-ID>');

For more information, see the TypeScript SDK Docs.

CreateLocation

Create and name a location under the organization you are currently authenticated to. Optionally, put the new location under a specified parent location.

Parameters:

  • org_id (str) (required): The ID of the organization to create the location under. You can obtain your organization ID from the Viam app’s organization settings page.
  • name (str) (required): Name of the location.
  • parent_location_id (str) (optional): Optional parent location to put the location under. Defaults to a root-level location if no location ID is provided.

Returns:

Raises:

  • (GRPCError): If either an invalid name (for example, “”), or parent location ID (for example, a nonexistent ID) is passed.

Example:

my_new_location = await cloud.create_location(org_id="<YOUR-ORG-ID>", name="Robotville", parent_location_id="111ab12345")

For more information, see the Python SDK Docs.

Parameters:

  • orgID (string) (required): The ID of the organization to create the location under. You can obtain your organization ID from the Viam app’s organization settings page.
  • name (string) (required): Name of the location.
  • parentLocationID (*string) (optional): Optional parent location to put the location under. Defaults to a root-level location if no location ID is provided.

Returns:

  • (*app.Location): The newly created location.
  • (error): An error, if one occurred.

Example:

parentLocationID := "111ab12345"
myNewLocation, err := client.CreateLocation(ctx, "<YOUR-ORG-ID>", "Robotville", &parentLocationID)
if err != nil {
    log.Fatalf("Failed to create location: %v", err)
}
fmt.Printf("Created location: %s\n", myNewLocation.Name)

For more information, see the Go SDK Docs.

Parameters:

  • organizationId (string) (required): The ID of the organization to create the location under.
  • name (string) (required): The name of the location to create.
  • parentLocationId (string) (optional): Optional name of a parent location to create the new location under.

Returns:

  • (Promise<undefined | Location>): The location object.

Example:

const location = await appClient.createLocation(
  '<YOUR-ORGANIZATION-ID>',
  'name'
);

For more information, see the TypeScript SDK Docs.

ListLocations

Get a list of all locations under the organization you are currently authenticated to.

Parameters:

  • org_id (str) (required): The ID of the org to list locations for. You can obtain your organization ID from the Viam app’s organization settings page.

Returns:

Example:

locations = await cloud.list_locations("<YOUR-ORG-ID>")

For more information, see the Python SDK Docs.

Parameters:

  • orgID (string) (required): The ID of the org to list locations for. You can obtain your organization ID from the Viam app’s organization settings page.

Returns:

  • ([]*app.Location): The list of locations.
  • (error): An error, if one occurred.

Example:

locations, err := client.ListLocations(ctx, "<YOUR-ORG-ID>")
if err != nil {
    log.Fatalf("Failed to list locations: %v", err)
}
for _, location := range locations {
    fmt.Printf("Location: %s (ID: %s)\n", location.Name, location.Id)
});

For more information, see the Go SDK Docs.

Parameters:

  • organizationId (string) (required): The ID of the organization to query.

Returns:

  • (Promise<Location[]>): A list of locations under the organization.

Example:

const locations = await appClient.listLocations(
  '<YOUR-ORGANIZATION-ID>'

For more information, see the TypeScript SDK Docs.

CreateKey

Create a new API key.

Parameters:

  • org_id (str) (required): The ID of the organization to create the key for. You can obtain your organization ID from the Viam app’s organization settings page.
  • authorizations (List[APIKeyAuthorization]) (required): A list of authorizations to associate with the key.
  • name (str) (optional): A name for the key. If None, defaults to the current timestamp.

Returns:

  • (Tuple[str, str]): The api key and api key ID.

Raises:

  • (GRPCError): If the authorizations list is empty.

Example:

from viam.app.app_client import APIKeyAuthorization

auth = APIKeyAuthorization(
    role="owner",
    resource_type="robot",
    resource_id="your-machine-id123"
)

api_key, api_key_id = cloud.create_key(
    org_id="<YOUR-ORG-ID>",
    authorizations=[auth],
    name="my_key"
)

For more information, see the Python SDK Docs.

Parameters:

  • orgID (string) (required): The ID of the organization to create the key for. You can obtain your organization ID from the Viam app’s organization settings page.
  • authorizations ([]*app.Authorization) (required): A list of authorizations to associate with the key.
  • name (string) (optional): A name for the key. If empty, defaults to the current timestamp.

Returns:

  • (string): The API key.
  • (string): The API key ID.
  • (error): An error, if one occurred.

Example:

auth := &app.Authorization{
    AuthorizationType: "role",
    AuthorizationId:   "owner",
    ResourceType:      "robot",
    ResourceId:        "your-machine-id123",
}

apiKey, apiKeyID, err := client.CreateKey(ctx, "<YOUR-ORG-ID>", []*app.Authorization{auth}, "my_key")
if err != nil {
    log.Fatalf("Failed to create key: %v", err)
}
fmt.Printf("Created API key: %s (ID: %s)\n", apiKey, apiKeyID)

For more information, see the Go SDK Docs.

Parameters:

  • authorizations (Authorization) (required): The list of authorizations to provide for the API key.
  • name (string) (optional): An optional name for the key. If none is passed, defaults to present timestamp.

Returns:

For more information, see the TypeScript SDK Docs.

ListKeys

List all keys for the organization that you are currently authenticated to.

Parameters:

  • org_id (str) (required): The ID of the organization to list API keys for. You can obtain your organization ID from the Viam app’s organization settings page.

Returns:

Example:

keys = await cloud.list_keys(org_id="<YOUR-ORG-ID>")

For more information, see the Python SDK Docs.

Parameters:

  • orgID (string) (required): The ID of the organization to list API keys for. You can obtain your organization ID from the Viam app’s organization settings page.

Returns:

  • ([]*app.APIKeyWithAuthorizations): The existing API keys and authorizations.
  • (error): An error, if one occurred.

Example:

keys, err := client.ListKeys(ctx, "<YOUR-ORG-ID>")
if err != nil {
    log.Fatalf("Failed to list keys: %v", err)
}
for _, key := range keys {
    fmt.Printf("API Key: %s\n", key.ApiKey.Name)
}

For more information, see the Go SDK Docs.

Parameters:

  • orgId (string) (required): The ID of the organization to query.

Returns:

Example:

const keys = await appClient.listKeys('<YOUR-ORGANIZATION-ID>');

For more information, see the TypeScript SDK Docs.

DeleteKey

Delete an API key.

Parameters:

  • id (str) (required): The ID of the API key.

Returns:

  • None.

Example:

await cloud.delete_key("key-id")

For more information, see the Python SDK Docs.

Parameters:

  • id (string) (required): The ID of the API key.

Returns:

  • (error): An error, if one occurred.

Example:

err := client.DeleteKey(ctx, "key-id")
if err != nil {
    log.Fatalf("Failed to delete key: %v", err)
}

For more information, see the Go SDK Docs.

Parameters:

  • id (string) (required): The ID of the key to delete.

Returns:

Example:

await appClient.deleteKey('<YOUR-KEY-ID>');

For more information, see the TypeScript SDK Docs.

RotateKey

Rotate an API key.

Parameters:

  • id (str) (required): The ID of the key to be rotated.

Returns:

  • (Tuple[str, str]): The API key and API key id.

Example:

id, key = await cloud.rotate_key("key-id")

For more information, see the Python SDK Docs.

Parameters:

  • id (string) (required): The ID of the key to be rotated.

Returns:

  • (string): The API key ID.
  • (string): The API key.
  • (error): An error, if one occurred.

Example:

keyID, key, err := client.RotateKey(ctx, "key-id")
if err != nil {
    log.Fatalf("Failed to rotate key: %v", err)
}
fmt.Printf("Rotated key: %s (ID: %s)\n", key, keyID)

For more information, see the Go SDK Docs.

Parameters:

  • id (string) (required): The ID of the key to rotate.

Returns:

Example:

const key = await appClient.rotateKey('<YOUR-KEY-ID>');

For more information, see the TypeScript SDK Docs.

Find part ID

To copy the ID of your machine part, select the part status dropdown to the right of your machine’s location and name on the top of its page and click the copy icon next to Part ID:

Part ID displayed in the Viam app.

Find machine ID

To copy the ID of your machine, click the (Actions) button in the upper-right corner of your machine’s page, then click Copy machine ID:

Machine ID in the actions dropdown in the Viam app.