Time-to-Live (TTL) for On-Demand Sandboxes

When you create an on-demand sandbox, you can configure an optional Time-to-Live (TTL) value that specifies how many hours the sandbox lasts. For example, if the sandbox has a TTL of 24, the sandbox lasts for 24 hours and then is automatically deleted.

TTL for a Sandbox

The maximum TTL for a sandbox is 2160 hours. A sandbox with a TTL value of 0 or less lasts until it is deleted.

Important: When the TTL value for a sandbox is reached, the sandbox is permanently deleted. Data from the sandbox is no longer available.

This snippet from the JSON body of a POST/sandboxes API call to create a sandbox sets the TTL value of the sandbox to 100 hours.

{
  "realm": "<your realm id>",
  "ttl": 100,
  
      }
   

After a sandbox is created, you can change its TTL value using a PATCH/sandboxes API call. This snippet from the JSON body of a PATCH/sandboxes{sandboxId} API call updates the TTL to 0, specifying that the sandbox lasts until it is deleted using a DELETE /sandboxes/{sandboxId} call.

{
  
  "ttl": 0,
  
      }
   

In the B2C Commerce Developer Sandbox REST API Swagger UI, the example to create a sandbox with a POST/sandboxes API call uses a TTL value of 24. If you don't change the TTL in the example request body, the sandbox is created with a TTL of 24 hours. To use a different TTL, update the ttl value in the example before clicking Try it out.

TTL for the Realm

Every realm has settings for default TTL and maximum TTL for all sandboxes in the realm. The default TTL for the realm is 24 hours. To change the default TTL for the realm, use a PATCH/realms/{realm}/configuration API call. You can also override the realm default for any sandbox in the realm by setting the TTL for that sandbox to a different value.

The default maximum TTL setting for a realm is 0, indicating that no maximum has been set. You can set a maximum TTL, up to 2160 hours, for all sandboxes in the realm using a PATCH/realms/{realm}/configuration API call. When a default maximum TTL is set for the realm, you get an error if you try to create a sandbox in the realm with a TTL higher than the maximum.

Best Practices for TTL

If you need a sandbox for a short-term use, specify a TTL that covers only the time required. If your project has an uncertain end date, configure the TTL as 0 or less so that the sandbox lasts until you delete it. As an alternative, use a large TTL, such as 2100 hours, but then manually delete the sandbox when the project is completed.

In the B2C Commerce Developer Sandbox REST API Swagger UI, the example to create a sandbox with a POST/sandboxes API call uses a TTL value of 24. If you use the Try it out feature to create a sandbox from the Swagger UI and don't change the TTL in the example request body, the sandbox has a TTL of 24 hours. To use a different TTL, update the ttl value in the Example before clicking Try it out.