Pinecone TypeScript SDK - v9.0.0
    Preparing search index...

    Class ApiKeysResource

    API keys authorize a Pinecone client to access a project. Access this resource through AdminClient.apiKeys; do not construct it directly. Use AdminClient.serviceAccounts for organization administration credentials.

    import { AdminClient } from '@pinecone-database/pinecone';

    const admin = new AdminClient();
    const result = await admin.apiKeys.list('8a3e2d1c-0b9f-4e6d-8c7b-5a4f3e2d1c0b');
    Index
    • Creates an API key for a project. Save its secret value; it cannot be retrieved later.

      Parameters

      • projectId: string

        The ID of the project the key will access.

      • options: CreateAPIKeyRequest

        The key name and access roles. Choose roles that match the operations the application needs.

      Returns Promise<APIKeyWithSecret>

      The key details in key and the secret in value.

      Errors.PineconeArgumentError when the project ID or key name is empty.

      import { AdminClient } from '@pinecone-database/pinecone';

      const admin = new AdminClient();
      const result = await admin.apiKeys.create('8a3e2d1c-0b9f-4e6d-8c7b-5a4f3e2d1c0b', {
      name: 'catalog-reader',
      roles: ['ProjectViewer'],
      });
      console.log(result.key.id);
    • Deletes an API key, revoking its access.

      Parameters

      • apiKeyId: string

        The ID of the API key to delete.

      Returns Promise<void>

      Resolves when the deletion request succeeds.

      Errors.PineconeArgumentError when apiKeyId is empty.

      import { AdminClient } from '@pinecone-database/pinecone';

      const admin = new AdminClient();
      await admin.apiKeys.delete('1c8c262b-6808-4aab-a277-75cac87b6e2f');
    • Retrieves an API key by ID. The secret value is not returned.

      Parameters

      • apiKeyId: string

        The API key ID returned when it was created or listed.

      Returns Promise<APIKey>

      The API key details and assigned roles, without the secret value.

      Errors.PineconeArgumentError when apiKeyId is empty.

      import { AdminClient } from '@pinecone-database/pinecone';

      const admin = new AdminClient();
      const result = await admin.apiKeys.describe('1c8c262b-6808-4aab-a277-75cac87b6e2f');
      console.log(result);
    • Lists the API keys in a project.

      Parameters

      • projectId: string

        The project whose API keys to list.

      Returns Promise<ListApiKeysResponse>

      Results in data.

      Errors.PineconeArgumentError when projectId is empty.

      import { AdminClient } from '@pinecone-database/pinecone';

      const admin = new AdminClient();
      const result = await admin.apiKeys.list('8a3e2d1c-0b9f-4e6d-8c7b-5a4f3e2d1c0b');
      console.log(result.data);
    • Updates an API key. Omitted fields remain unchanged.

      Parameters

      • apiKeyId: string

        The ID of the API key to update.

      • options: UpdateAPIKeyRequest

        Fields to change. Providing roles replaces the existing roles.

      Returns Promise<APIKey>

      The updated API key details.

      Errors.PineconeArgumentError when apiKeyId is empty.

      import { AdminClient } from '@pinecone-database/pinecone';

      const admin = new AdminClient();
      const result = await admin.apiKeys.update('1c8c262b-6808-4aab-a277-75cac87b6e2f', {
      name: 'catalog-reader',
      });
      console.log(result);