diff --git a/.stats.yml b/.stats.yml
index 14c789bf..239e17b7 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
-configured_endpoints: 19
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-9563716c7b08b8936ba450ad05005d12cf5ca3b9a37fab8126ed372e422d6de6.yml
+configured_endpoints: 21
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-fd67aea6883f1ee9e46f31a42d3940f0acb1749e787055bd9b9f278b20fa53ec.yml
diff --git a/api.md b/api.md
index 48d1c9a8..9a25fe32 100644
--- a/api.md
+++ b/api.md
@@ -70,6 +70,7 @@ Methods:
Types:
+- DeletedMessageBatch
- MessageBatch
- MessageBatchCanceledResult
- MessageBatchErroredResult
@@ -84,6 +85,7 @@ Methods:
- client.messages.batches.create({ ...params }) -> MessageBatch
- client.messages.batches.retrieve(messageBatchId) -> MessageBatch
- client.messages.batches.list({ ...params }) -> MessageBatchesPage
+- client.messages.batches.delete(messageBatchId) -> DeletedMessageBatch
- client.messages.batches.cancel(messageBatchId) -> MessageBatch
- client.messages.batches.results(messageBatchId) -> Response
@@ -175,6 +177,7 @@ Methods:
Types:
+- BetaDeletedMessageBatch
- BetaMessageBatch
- BetaMessageBatchCanceledResult
- BetaMessageBatchErroredResult
@@ -189,5 +192,6 @@ Methods:
- client.beta.messages.batches.create({ ...params }) -> BetaMessageBatch
- client.beta.messages.batches.retrieve(messageBatchId, { ...params }) -> BetaMessageBatch
- client.beta.messages.batches.list({ ...params }) -> BetaMessageBatchesPage
+- client.beta.messages.batches.delete(messageBatchId, { ...params }) -> BetaDeletedMessageBatch
- client.beta.messages.batches.cancel(messageBatchId, { ...params }) -> BetaMessageBatch
- client.beta.messages.batches.results(messageBatchId, { ...params }) -> Response
diff --git a/src/resources/beta/messages/batches.ts b/src/resources/beta/messages/batches.ts
index 0a863e64..b564cb1c 100644
--- a/src/resources/beta/messages/batches.ts
+++ b/src/resources/beta/messages/batches.ts
@@ -85,6 +85,35 @@ export class Batches extends APIResource {
});
}
+ /**
+ * This endpoint is idempotent and can be used to poll for Message Batch
+ * completion. To access the results of a Message Batch, make a request to the
+ * `results_url` field in the response.
+ */
+ delete(
+ messageBatchId: string,
+ params?: BatchDeleteParams,
+ options?: Core.RequestOptions,
+ ): Core.APIPromise;
+ delete(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise;
+ delete(
+ messageBatchId: string,
+ params: BatchDeleteParams | Core.RequestOptions = {},
+ options?: Core.RequestOptions,
+ ): Core.APIPromise {
+ if (isRequestOptions(params)) {
+ return this.delete(messageBatchId, {}, params);
+ }
+ const { betas } = params;
+ return this._client.delete(`/v1/messages/batches/${messageBatchId}?beta=true`, {
+ ...options,
+ headers: {
+ 'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
+ ...options?.headers,
+ },
+ });
+ }
+
/**
* Batches may be canceled any time before processing ends. Once cancellation is
* initiated, the batch enters a `canceling` state, at which time the system may
@@ -168,6 +197,20 @@ export class Batches extends APIResource {
export class BetaMessageBatchesPage extends Page {}
+export interface BetaDeletedMessageBatch {
+ /**
+ * ID of the Message Batch.
+ */
+ id: string;
+
+ /**
+ * Deleted object type.
+ *
+ * For Message Batches, this is always `"message_batch_deleted"`.
+ */
+ type: 'message_batch_deleted';
+}
+
export interface BetaMessageBatch {
/**
* Unique object identifier.
@@ -374,6 +417,13 @@ export interface BatchListParams extends PageParams {
betas?: Array;
}
+export interface BatchDeleteParams {
+ /**
+ * Optional header to specify the beta version(s) you want to use.
+ */
+ betas?: Array;
+}
+
export interface BatchCancelParams {
/**
* Optional header to specify the beta version(s) you want to use.
@@ -392,6 +442,7 @@ Batches.BetaMessageBatchesPage = BetaMessageBatchesPage;
export declare namespace Batches {
export {
+ type BetaDeletedMessageBatch as BetaDeletedMessageBatch,
type BetaMessageBatch as BetaMessageBatch,
type BetaMessageBatchCanceledResult as BetaMessageBatchCanceledResult,
type BetaMessageBatchErroredResult as BetaMessageBatchErroredResult,
@@ -404,6 +455,7 @@ export declare namespace Batches {
type BatchCreateParams as BatchCreateParams,
type BatchRetrieveParams as BatchRetrieveParams,
type BatchListParams as BatchListParams,
+ type BatchDeleteParams as BatchDeleteParams,
type BatchCancelParams as BatchCancelParams,
type BatchResultsParams as BatchResultsParams,
};
diff --git a/src/resources/beta/messages/index.ts b/src/resources/beta/messages/index.ts
index 2cf85964..e6b260ab 100644
--- a/src/resources/beta/messages/index.ts
+++ b/src/resources/beta/messages/index.ts
@@ -3,6 +3,7 @@
export {
BetaMessageBatchesPage,
Batches,
+ type BetaDeletedMessageBatch,
type BetaMessageBatch,
type BetaMessageBatchCanceledResult,
type BetaMessageBatchErroredResult,
@@ -14,6 +15,7 @@ export {
type BatchCreateParams,
type BatchRetrieveParams,
type BatchListParams,
+ type BatchDeleteParams,
type BatchCancelParams,
type BatchResultsParams,
} from './batches';
diff --git a/src/resources/beta/messages/messages.ts b/src/resources/beta/messages/messages.ts
index 186a6c36..92239cd8 100644
--- a/src/resources/beta/messages/messages.ts
+++ b/src/resources/beta/messages/messages.ts
@@ -10,10 +10,12 @@ import * as BatchesAPI from './batches';
import {
BatchCancelParams,
BatchCreateParams,
+ BatchDeleteParams,
BatchListParams,
BatchResultsParams,
BatchRetrieveParams,
Batches,
+ BetaDeletedMessageBatch,
BetaMessageBatch,
BetaMessageBatchCanceledResult,
BetaMessageBatchErroredResult,
@@ -1115,6 +1117,7 @@ export declare namespace Messages {
export {
Batches as Batches,
+ type BetaDeletedMessageBatch as BetaDeletedMessageBatch,
type BetaMessageBatch as BetaMessageBatch,
type BetaMessageBatchCanceledResult as BetaMessageBatchCanceledResult,
type BetaMessageBatchErroredResult as BetaMessageBatchErroredResult,
@@ -1127,6 +1130,7 @@ export declare namespace Messages {
type BatchCreateParams as BatchCreateParams,
type BatchRetrieveParams as BatchRetrieveParams,
type BatchListParams as BatchListParams,
+ type BatchDeleteParams as BatchDeleteParams,
type BatchCancelParams as BatchCancelParams,
type BatchResultsParams as BatchResultsParams,
};
diff --git a/src/resources/messages/batches.ts b/src/resources/messages/batches.ts
index b4fd45e8..3d9539cf 100644
--- a/src/resources/messages/batches.ts
+++ b/src/resources/messages/batches.ts
@@ -49,6 +49,15 @@ export class Batches extends APIResource {
return this._client.getAPIList('/v1/messages/batches', MessageBatchesPage, { query, ...options });
}
+ /**
+ * This endpoint is idempotent and can be used to poll for Message Batch
+ * completion. To access the results of a Message Batch, make a request to the
+ * `results_url` field in the response.
+ */
+ delete(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise {
+ return this._client.delete(`/v1/messages/batches/${messageBatchId}`, options);
+ }
+
/**
* Batches may be canceled any time before processing ends. Once cancellation is
* initiated, the batch enters a `canceling` state, at which time the system may
@@ -90,6 +99,20 @@ export class Batches extends APIResource {
export class MessageBatchesPage extends Page {}
+export interface DeletedMessageBatch {
+ /**
+ * ID of the Message Batch.
+ */
+ id: string;
+
+ /**
+ * Deleted object type.
+ *
+ * For Message Batches, this is always `"message_batch_deleted"`.
+ */
+ type: 'message_batch_deleted';
+}
+
export interface MessageBatch {
/**
* Unique object identifier.
@@ -283,6 +306,7 @@ Batches.MessageBatchesPage = MessageBatchesPage;
export declare namespace Batches {
export {
+ type DeletedMessageBatch as DeletedMessageBatch,
type MessageBatch as MessageBatch,
type MessageBatchCanceledResult as MessageBatchCanceledResult,
type MessageBatchErroredResult as MessageBatchErroredResult,
diff --git a/src/resources/messages/index.ts b/src/resources/messages/index.ts
index 10308d2a..1c9178ad 100644
--- a/src/resources/messages/index.ts
+++ b/src/resources/messages/index.ts
@@ -3,6 +3,7 @@
export {
MessageBatchesPage,
Batches,
+ type DeletedMessageBatch,
type MessageBatch,
type MessageBatchCanceledResult,
type MessageBatchErroredResult,
diff --git a/src/resources/messages/messages.ts b/src/resources/messages/messages.ts
index a1affbf5..c75a62f5 100644
--- a/src/resources/messages/messages.ts
+++ b/src/resources/messages/messages.ts
@@ -9,6 +9,7 @@ import {
BatchCreateParams,
BatchListParams,
Batches,
+ DeletedMessageBatch,
MessageBatch,
MessageBatchCanceledResult,
MessageBatchErroredResult,
@@ -1114,6 +1115,7 @@ export declare namespace Messages {
export {
Batches as Batches,
+ type DeletedMessageBatch as DeletedMessageBatch,
type MessageBatch as MessageBatch,
type MessageBatchCanceledResult as MessageBatchCanceledResult,
type MessageBatchErroredResult as MessageBatchErroredResult,
diff --git a/tests/api-resources/beta/messages/batches.test.ts b/tests/api-resources/beta/messages/batches.test.ts
index e395910a..1ebd0cf4 100644
--- a/tests/api-resources/beta/messages/batches.test.ts
+++ b/tests/api-resources/beta/messages/batches.test.ts
@@ -132,6 +132,35 @@ describe('resource batches', () => {
).rejects.toThrow(Anthropic.NotFoundError);
});
+ test('delete', async () => {
+ const responsePromise = client.beta.messages.batches.delete('message_batch_id');
+ const rawResponse = await responsePromise.asResponse();
+ expect(rawResponse).toBeInstanceOf(Response);
+ const response = await responsePromise;
+ expect(response).not.toBeInstanceOf(Response);
+ const dataAndResponse = await responsePromise.withResponse();
+ expect(dataAndResponse.data).toBe(response);
+ expect(dataAndResponse.response).toBe(rawResponse);
+ });
+
+ test('delete: request options instead of params are passed correctly', async () => {
+ // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
+ await expect(
+ client.beta.messages.batches.delete('message_batch_id', { path: '/_stainless_unknown_path' }),
+ ).rejects.toThrow(Anthropic.NotFoundError);
+ });
+
+ test('delete: request options and params are passed correctly', async () => {
+ // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
+ await expect(
+ client.beta.messages.batches.delete(
+ 'message_batch_id',
+ { betas: ['string'] },
+ { path: '/_stainless_unknown_path' },
+ ),
+ ).rejects.toThrow(Anthropic.NotFoundError);
+ });
+
test('cancel', async () => {
const responsePromise = client.beta.messages.batches.cancel('message_batch_id');
const rawResponse = await responsePromise.asResponse();
diff --git a/tests/api-resources/messages/batches.test.ts b/tests/api-resources/messages/batches.test.ts
index 26efdbc8..bc92b160 100644
--- a/tests/api-resources/messages/batches.test.ts
+++ b/tests/api-resources/messages/batches.test.ts
@@ -118,6 +118,24 @@ describe('resource batches', () => {
).rejects.toThrow(Anthropic.NotFoundError);
});
+ test('delete', async () => {
+ const responsePromise = client.messages.batches.delete('message_batch_id');
+ const rawResponse = await responsePromise.asResponse();
+ expect(rawResponse).toBeInstanceOf(Response);
+ const response = await responsePromise;
+ expect(response).not.toBeInstanceOf(Response);
+ const dataAndResponse = await responsePromise.withResponse();
+ expect(dataAndResponse.data).toBe(response);
+ expect(dataAndResponse.response).toBe(rawResponse);
+ });
+
+ test('delete: request options instead of params are passed correctly', async () => {
+ // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
+ await expect(
+ client.messages.batches.delete('message_batch_id', { path: '/_stainless_unknown_path' }),
+ ).rejects.toThrow(Anthropic.NotFoundError);
+ });
+
test('cancel', async () => {
const responsePromise = client.messages.batches.cancel('message_batch_id');
const rawResponse = await responsePromise.asResponse();