210 210
211 211
212 212
213Connect your own AWS S3 bucket, Azure Blob container, Google Cloud Storage bucket, or Oracle Cloud Infrastructure (OCI) Object Storage bucket to an OpenAI project. Follow the setup steps for your cloud, then register and validate the connection.213Connect your own AWS S3 bucket, Azure Blob container, Google Cloud Storage bucket, or Oracle Cloud Infrastructure (OCI) Object Storage bucket to an OpenAI project. For a direct connection, follow the setup steps for your cloud, then register and validate the connection. You can also register a custom HTTPS endpoint to route records to customer storage. This option takes more work than a direct cloud connection because you must build and operate a service that verifies signed requests, stores records, and returns them for review.
214 214
215ZDR with PSP is enabled per project. Once enabled, the PSP policy applies to all API traffic in that project, including requests to models that do not otherwise require PSP. To use ZDR without PSP for eligible models, send those requests through a separate project configured for ZDR without PSP.215ZDR with PSP is enabled per project. Once enabled, the PSP policy applies to all API traffic in that project, including requests to models that do not otherwise require PSP. To use ZDR without PSP for eligible models, send those requests through a separate project configured for ZDR without PSP.
216 216
219- Organizations already approved for Zero Data Retention can set up ZDR with PSP directly in the API console. If your organization isn't approved for ZDR, see the [eligibility and approval requirements](https://developers.openai.com/api/docs/guides/your-data#data-retention-controls-for-abuse-monitoring).219- Organizations already approved for Zero Data Retention can set up ZDR with PSP directly in the API console. If your organization isn't approved for ZDR, see the [eligibility and approval requirements](https://developers.openai.com/api/docs/guides/your-data#data-retention-controls-for-abuse-monitoring).
220- You can choose any supported storage region that meets your project's data residency requirements. You need permission to create storage and delegate access in your cloud account.220- You can choose any supported storage region that meets your project's data residency requirements. You need permission to create storage and delegate access in your cloud account.
221- Have an organization administrator register and validate storage in the API console. For the Management API, use an OpenAI organization Admin API key. Project administrators can view guidance and status; a project inference key won't work for the Management API calls.221- Have an organization administrator register and validate storage in the API console. For the Management API, use an OpenAI organization Admin API key. Project administrators can view guidance and status; a project inference key won't work for the Management API calls.
222- If you need to route encrypted safety records by customer or geography, skip to [Option 3: Set up a custom endpoint](#option-3-set-up-a-custom-endpoint). You’ll need an HTTPS endpoint that you operate. This setup can support zero data retention (ZDR) or data isolation commitments you’ve made to your customers.
222 223
223### Open storage setup in the API console224### Open storage setup in the API console
224 225
609 610
610### Register your storage611### Register your storage
611 612
612After completing the cloud setup above, select an eligible base data retention policy for the project. Private Safety Processing can be used with Zero Data Retention or Modified Abuse Monitoring, and the selected policy remains active while Private Safety Processing uses your connected storage. Then use either the API console or the Management API to register and validate your storage. You only need to use one method.613Select an eligible base data retention policy for the project. Private Safety Processing can be used with Zero Data Retention or Modified Abuse Monitoring, and the selected policy remains active while Private Safety Processing uses your connected storage. If you completed the cloud setup above, register and validate your storage using the API console (option 1) or the Management API (option 2). If OpenAI will send records to an HTTPS endpoint you operate, follow option 3.
614
615
616
617<a id="option-1-api-console"></a>
618
619
613 620
614#### Option 1: API console621#### Option 1: API console
615 622
663 672
664If validation fails after registration, fix the reported issue and select **Retry validation**. To resume later, select the destination under **Registered storage** and choose **Validate storage**. If the API console can't refresh the result, select **Refresh status** before starting over.673If validation fails after registration, fix the reported issue and select **Retry validation**. To resume later, select the destination under **Registered storage** and choose **Validate storage**. If the API console can't refresh the result, select **Refresh status** before starting over.
665 674
675
676
677
678
679
680
681<a id="option-2-management-api"></a>
682
683
684
666#### Option 2: Management API685#### Option 2: Management API
667 686
687
688
668Use an organization Admin API key for this method. Set the project's base data retention policy, register storage, then follow [**4. Verify your setup**](#4-verify-your-setup) to run validation.689Use an organization Admin API key for this method. Set the project's base data retention policy, register storage, then follow [**4. Verify your setup**](#4-verify-your-setup) to run validation.
669 690
670##### 1. Prepare your API settings691##### 1. Prepare your API settings
799 -H "OpenAI-Organization: $OPENAI_ORG_ID"820 -H "OpenAI-Organization: $OPENAI_ORG_ID"
800```821```
801 822
802For either method, open **Project Settings > Data retention** and select **Refresh**. Confirm the destination, provider, geography, and **Validated** status, then check that the selected base policy shows Private Safety Processing. The organization Data retention table also shows storage and status for each project.823
824
825
826
827
828
829<a id="option-3-set-up-a-custom-endpoint"></a>
830
831
832
833#### Option 3: Set up a custom endpoint
834
835
836
837If you serve customers with zero data retention requirements or have customer data isolation commitments, you will need to set up a custom endpoint to isolate the encrypted safety record by customer-specific, geography specific buckets. Your application will call the Responses API as usual with a storage key attached. When OpenAI needs to retain a record, it sends the encrypted bytes to an HTTPS endpoint you run.
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855##### 1. Set the project's base retention policy
856
857Use an organization Admin API key to set an explicit policy on the project that will send Responses requests. In the path, replace `proj_123` with your project ID. In the JSON body, set `retention_type` to `zero_data_retention` or `modified_abuse_monitoring`. An inherited organization default doesn't satisfy the validation requirement.
858
859**Your request**
860
861```http snippet=reference reason="HTTP message format"
862POST /v1/organization/projects/proj_123/data_retention HTTP/1.1
863Host: api.openai.com
864Authorization: Bearer <OPENAI_ADMIN_KEY>
865Content-Type: application/json
866
867{"retention_type":"zero_data_retention"}
868```
869
870**OpenAI responds** with `200 OK` and your selected policy. For this example, the response includes:
871
872```json snippet=reference reason="Example JSON payload"
873{
874 "object": "project.data_retention",
875 "type": "zero_data_retention"
876}
877```
878
879This sets the base policy. Private Safety Processing becomes active for the project when storage validation succeeds in step 3.
880
881##### 2. Register your endpoint
882
883```http snippet=reference reason="HTTP message format"
884POST https://api.openai.com/v1/organization/external_storage
885```
886
887Use an organization admin API key with `api.external_storage.write`. For a Global project, include the destination geography. For a fixed-region project, you can omit it.
888
889```json snippet=reference reason="Example JSON payload"
890{
891 "project_id": "proj_123",
892 "provider": {
893 "type": "custom_endpoint",
894 "endpoint_url": "https://storage.example.com/custom-endpoint",
895 "geography": "EU"
896 }
897}
898```
899
900Response: `200 OK`
901
902```json snippet=reference reason="Example JSON payload"
903{
904 "object": "organization.external_storage",
905 "id": "extstorage_abc123",
906 "project_id": "proj_123",
907 "provider": {
908 "type": "custom_endpoint",
909 "endpoint_url": "https://storage.example.com/custom-endpoint",
910 "signing_secret": "whsec_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
911 "signing_secret_hint": "whsec_...AAA="
912 },
913 "geography": "EU",
914 "status": "pending",
915 "created_at": 1793880000
916}
917```
918
919**Save your signing secret.** Store `provider.signing_secret` in your secret manager. You'll use it to [verify requests from OpenAI](#verify-requests-from-openai). The API returns the full secret only at registration.
920
921##### 3. Validate your endpoint
922
923Implement `POST {endpoint_url}/v1/validate` on your server.
924
925**You request validation.** Send the registration ID from step 2 in the URL. Authenticate with your organization Admin API key and leave the body empty.
926
927```http snippet=reference reason="HTTP message format"
928POST /v1/organization/external_storage/extstorage_abc123/validate HTTP/1.1
929Host: api.openai.com
930Authorization: Bearer <OPENAI_ADMIN_KEY>
931Content-Length: 0
932```
933
934**OpenAI sends a signed challenge**
935
936```http snippet=reference reason="HTTP message format"
937POST /custom-endpoint/v1/validate HTTP/1.1
938Host: storage.example.com
939Content-Type: application/json
940webhook-id: probe_a81f907c2b6d4e13a5709f28c6103eb4
941webhook-timestamp: 1793880000
942webhook-signature: v1,R2MM/gN/BbBWiq51ShHlMTY/D8Qlsd2nuzWyZUNirm4=
943
944{"challenge": "a81f907c2b6d4e13a5709f28c6103eb4"}
945```
946
947**You verify the signature and return the challenge.** [Verify the raw request body](#verify-requests-from-openai) with the signing secret from step 2. If verification succeeds, parse the JSON and return the received `challenge` value.
948
949```http snippet=reference reason="HTTP message format"
950HTTP/1.1 200 OK
951Content-Type: application/json
952
953{"challenge":"a81f907c2b6d4e13a5709f28c6103eb4"}
954```
955
956**Check the registration status.** OpenAI responds to your original request with `200 OK` and the updated registration. Look for `"status": "validated"` before sending a Responses request.
957
958```http snippet=reference reason="HTTP message format"
959HTTP/1.1 200 OK
960Content-Type: application/json
961
962{
963 "object": "organization.external_storage",
964 "id": "extstorage_abc123",
965 "project_id": "proj_123",
966 "status": "validated",
967 "provider": {
968 "type": "custom_endpoint",
969 "endpoint_url": "https://storage.example.com/custom-endpoint",
970 "signing_secret_hint": "whsec_...AAA="
971 },
972 "geography": "EU",
973 "created_at": 1793880000
974}
975```
976
977##### 4. Send a request
978
979```http snippet=reference reason="HTTP message format"
980POST https://api.openai.com/v1/responses
981```
982
983Use a PSP-enabled project API key with `api.responses.write`. Pick an opaque routing key that your server recognizes, e.g. a customer identifier and geography combination. Your custom endpoint will use this later to route OpenAI’s retention requests.
984
985```json snippet=reference reason="Example JSON payload"
986{
987 "model": "<model-id>",
988 "input": "Summarize this account update.",
989 "storage_routing": {
990 "routing_key": "customer_1-us"
991 }
992}
993```
994
995##### 5. Accept the encrypted record
996
997You implement `POST {endpoint_url}/v1/records` on your server.
998
999**OpenAI sends the encrypted record.** The signed multipart request includes the encrypted bytes in the `ciphertext` part and a routing key that identifies your end-customer’s storage.
1000
1001```http snippet=reference reason="HTTP message format"
1002POST /custom-endpoint/v1/records HTTP/1.1
1003Host: storage.example.com
1004Content-Type: multipart/form-data; boundary=custom-endpoint-example
1005webhook-id: cobj_456
1006webhook-timestamp: 1793880060
1007webhook-signature: v1,MLAK7AYd/cYh1U8Yqo28Lx2SEds5nLb/IYulCiTFXJA=
1008
1009--custom-endpoint-example
1010Content-Disposition: form-data; name="type"
1011
1012record.write
1013--custom-endpoint-example
1014Content-Disposition: form-data; name="id"
1015
1016cobj_456
1017--custom-endpoint-example
1018Content-Disposition: form-data; name="storage_routing[routing_key]"
1019
1020customer_1-us
1021--custom-endpoint-example
1022Content-Disposition: form-data; name="expires_at"
1023
10241796472000
1025--custom-endpoint-example
1026Content-Disposition: form-data; name="ciphertext"; filename="record.bin"
1027Content-Type: application/octet-stream
1028
1029<raw encrypted bytes>
1030--custom-endpoint-example--
1031```
1032
1033**You return `202 Accepted` with the record ID.** [Verify the request signature](#verify-requests-from-openai) before parsing the multipart body. Once your server accepts the write, return the `id` from that request.
1034
1035```http snippet=reference reason="HTTP message format"
1036HTTP/1.1 202 Accepted
1037Content-Type: application/json
1038
1039{ "id": "cobj_456" }
1040```
1041
1042You can finish storing the bytes asynchronously. OpenAI retries unacknowledged writes with backoff, so use the ID to recognize duplicates. Keep the ID with the storage location and delete the record at `expires_at` (Unix seconds).
1043
1044##### 6. Return the record for review
1045
1046You implement `GET {endpoint_url}/v1/records/{id}/content` on your server. During a safety review, OpenAI calls this endpoint to retrieve an unexpired record.
1047
1048**OpenAI sends a signed GET request**
1049
1050```http snippet=reference reason="HTTP message format"
1051GET /custom-endpoint/v1/records/cobj_456/content HTTP/1.1
1052Host: storage.example.com
1053webhook-id: cobj_456
1054webhook-timestamp: 1793883600
1055webhook-signature: v1,PYSp9wJfLMP9tl+6O476HMV+8wuFZ/q6X/gPirSbdBQ=
1056```
1057
1058**You return the encrypted record.** [Verify the request signature](#verify-requests-from-openai) and apply your access policy. If the request is authorized, look up the record by ID and return the original encrypted bytes. Send those bytes directly in the response body, without gzip compression, additional encryption, or any other encoding.
1059
1060```http snippet=reference reason="HTTP message format"
1061HTTP/1.1 200 OK
1062Content-Type: application/octet-stream
1063
1064<the same encrypted bytes accepted for cobj_456>
1065```
1066
1067OpenAI decrypts the record for review.
1068
1069##### Verify requests from OpenAI
1070
1071Verify each callback with the signing secret for its registration. If verification fails, return `401` before echoing a challenge, accepting a write, or returning a record.
1072
1073The verifier reads the signed bytes from the incoming request. The examples use a Fetch API `Request` in Node.js and a FastAPI `Request` in Python.
1074
1075- **POST:** Use the exact request body. Read it before parsing JSON or multipart data so that whitespace, multipart boundaries, and binary data are preserved.
1076- **GET:** Use the bytes of `GET`, one space, and the original public request path, including the registered path prefix. For the example above, the signed content is `GET /custom-endpoint/v1/records/cobj_456/content`.
1077
1078Verify a callback signature
1079
1080```typescript
1081import { createHmac, timingSafeEqual } from "node:crypto";
1082
1083async function verifyCallback(request: Request, secret: string) {
1084 const headers = request.headers;
1085 const id = headers.get("webhook-id");
1086 const timestamp = headers.get("webhook-timestamp");
1087 const signatures = headers.get("webhook-signature");
1088 if (!id || !timestamp || !signatures || !/^\d+$/.test(timestamp))
1089 return false;
1090
1091 // A short time window limits how long someone can replay a signed request.
1092 if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
1093
1094 // The whsec_ prefix identifies the secret. The rest encodes the HMAC key.
1095 if (!secret.startsWith("whsec_")) throw new Error("Invalid signing secret");
1096 const key = Buffer.from(secret.slice("whsec_".length), "base64");
1097 if (key.length !== 32) throw new Error("Invalid signing secret");
1098 // GET signs the public path. POST signs the body before any parsing.
1099 let signedContent: string | Uint8Array;
1100 if (request.method === "GET") {
1101 signedContent = "GET " + new URL(request.url).pathname;
1102 } else if (request.method === "POST") {
1103 signedContent = new Uint8Array(await request.clone().arrayBuffer());
1104 } else {
1105 return false;
1106 }
1107 const digest = createHmac("sha256", key)
1108 .update(`${id}.${timestamp}.`)
1109 .update(signedContent)
1110 .digest("base64");
1111
1112 // Accept any matching v1 signature using a constant-time comparison.
1113 const expected = Buffer.from(`v1,${digest}`);
1114 return signatures.split(/\s+/).some((value) => {
1115 const candidate = Buffer.from(value);
1116 return (
1117 candidate.length === expected.length &&
1118 timingSafeEqual(candidate, expected)
1119 );
1120 });
1121}
1122```
1123
1124```python
1125import base64
1126import hashlib
1127import hmac
1128import time
1129
1130from fastapi import Request
1131
1132
1133async def verify_callback(request: Request, secret: str) -> bool:
1134 headers = request.headers
1135 delivery_id = headers.get("webhook-id")
1136 timestamp = headers.get("webhook-timestamp", "")
1137 signatures = headers.get("webhook-signature")
1138 if (
1139 not delivery_id
1140 or not signatures
1141 or not (timestamp.isascii() and timestamp.isdecimal())
1142 ):
1143 return False
1144
1145 # A short time window limits how long someone can replay a signed request.
1146 if abs(time.time() - float(timestamp)) > 300:
1147 return False
1148
1149 # The whsec_ prefix identifies the secret. The rest encodes the HMAC key.
1150 if not secret.startswith("whsec_"):
1151 raise ValueError("Invalid signing secret")
1152 key = base64.b64decode(secret.removeprefix("whsec_"), validate=True)
1153 if len(key) != 32:
1154 raise ValueError("Invalid signing secret")
1155 mac = hmac.new(key, f"{delivery_id}.{timestamp}.".encode(), hashlib.sha256)
1156 # GET signs the encoded public path. POST signs the body before any parsing.
1157 if request.method == "GET":
1158 mac.update(b"GET " + request.scope["raw_path"])
1159 elif request.method == "POST":
1160 mac.update(await request.body())
1161 else:
1162 return False
1163
1164 # Accept any matching v1 signature using a constant-time comparison.
1165 expected = b"v1," + base64.b64encode(mac.digest())
1166 return any(
1167 hmac.compare_digest(value.encode(), expected) for value in signatures.split()
1168 )
1169```
1170
1171
1172
1173
1174
1175
1176After validating your storage configuration, open **Project Settings > Data retention** and select **Refresh**. Confirm the destination, provider, geography, and **Validated** status, then check that the selected base policy shows Private Safety Processing. The organization Data retention table also shows storage and status for each project.
803 1177
8041178
805 1179