Sandbox is safe place for executing semi trusted scripts, applications involving third party API needs. There are 3 sandboxes where user's code can run:
Safe access sandbox: User can create stored procedures, triggers, functions; data type's etc but cannot access memory, or disk, or create files.
External access sandbox: User can access file system outside the box, leverage classes but cannot manipulate threads, memory allocations etc.
Unsafe access sandbox: User has access to memory management, and threads. Allows users to create unsafe and untrusted code.