> ## Documentation Index
> Fetch the complete documentation index at: https://code.storage/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# getEphemeralRemoteURL()

> Generate authenticated Git URLs that point to the +ephemeral namespace.

Returns a JWT-authenticated remote URL for the `+ephemeral` namespace. Refs that you push through
this URL do not mirror to an upstream host. They remain separate from refs in the default namespace.

<CodeGroup>
  ```typescript TypeScript theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
  // Default: read/write access, 1-year TTL
  const ephemeralUrl = await repo.getEphemeralRemoteURL();
  // Returns: https://t:JWT@your-name.code.storage/repo-id+ephemeral.git

  // Short-lived URL for a single agent run
  const sandboxUrl = await repo.getEphemeralRemoteURL({
    permissions: ['git:read', 'git:write'],
    ttl: 3600,
  });

  // Disable force push on every ephemeral ref
  const safeEphemeralUrl = await repo.getEphemeralRemoteURL({
    refPolicies: [{ pattern: 'refs/namespaces/ephemeral/*', ops: ['no-force-push'] }],
  });
  ```

  ```python Python theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
  # Default: read/write access, 1-year TTL
  ephemeral_url = await repo.get_ephemeral_remote_url()
  # Returns: https://t:JWT@your-name.code.storage/repo-id+ephemeral.git

  # Short-lived URL for a single agent run
  sandbox_url = await repo.get_ephemeral_remote_url(
      permissions=['git:read', 'git:write'],
      ttl=3600,
  )

  # Disable force push on every ephemeral ref
  safe_ephemeral_url = await repo.get_ephemeral_remote_url(
      ref_policies=[{"pattern": "refs/namespaces/ephemeral/*", "ops": ["no-force-push"]}],
  )
  ```

  ```go Go theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
  // Default: read/write access, 1-year TTL
  ephemeralURL, err := repo.EphemeralRemoteURL(context.Background(), storage.RemoteURLOptions{})
  fmt.Println(ephemeralURL)
  // Prints: https://t:JWT@your-name.code.storage/repo-id+ephemeral.git

  // Short-lived URL for a single agent run
  sandboxURL, err := repo.EphemeralRemoteURL(context.Background(), storage.RemoteURLOptions{
  	Permissions: []storage.Permission{
  		storage.PermissionGitRead,
  		storage.PermissionGitWrite,
  	},
  	TTL: time.Hour,
  })

  // Disable force push on every ephemeral ref
  safeEphemeralURL, err := repo.EphemeralRemoteURL(context.Background(), storage.RemoteURLOptions{
  	RefPolicies: storage.RefPolicyList{
  		{Pattern: "refs/namespaces/ephemeral/*", Ops: storage.Ops{storage.OpNoForcePush}},
  	},
  })
  ```
</CodeGroup>

## Options

<ParamField path="permissions" type="string[]">
  Array of permissions. Defaults to `["git:read", "git:write"]`. Accepts `git:read`, `git:write`,
  `repo:write`, and `org:read`. See [Authentication](/docs/getting-started/authentication) for what each
  scope grants.
</ParamField>

<ParamField path="ttl" type="number">
  Token TTL in seconds. Defaults to 1 year.
</ParamField>

<ParamField path="refPolicies" type="object[]">
  Ordered ref policy rules (`{ pattern, ops? }`). Code Storage uses the first rule that matches the target ref.

  Code Storage stores an ephemeral branch under `refs/namespaces/ephemeral/refs/heads/`. A plain
  `refs/heads/*` pattern does not match it.

  Use a complete namespaced pattern or `*`. Use `ref_policies` in Python. Use `RefPolicies` with
  `storage.RefPolicyList` in Go.

  See [`getRemoteURL()`](/docs/reference/sdk/get-remote-url) for operations. See
  [Ref Policies](/docs/guides/ref-policies#apply-policies-to-ephemeral-branches) for patterns.
</ParamField>

<ParamField path="ops" type="string[]" deprecated>
  Repo-wide policy ops. The gateway folds them into a catch-all `*` rule on verify. Use
  `refPolicies` instead. See [Ref Policies](/docs/guides/ref-policies).
</ParamField>

## Response

Returns a `string` containing the HTTPS Git remote URL with embedded JWT authentication:

```
https://t:{jwt}@{org}.code.storage/{repo-id}+ephemeral.git
```

## Usage

Use the URL as a standard Git remote. Push and fetch work with ordinary Git commands:

```bash theme={"theme":{"light":"github-light","dark":"min-dark"}}
git remote add ephemeral <url>
git push ephemeral feature-branch
git fetch ephemeral feature-branch
```

<Note>
  The remote advertises ephemeral refs only. It does not show refs from the default namespace. The
  normal repository remote does not show ephemeral refs.
</Note>

See [Ephemeral Namespace](/docs/guides/ephemeral-branches) for promotion workflows and the
[Connect a Sandbox guide](/docs/guides/sandboxes) for agent isolation patterns.
