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

# Class: AuthorizationError

Defined in: [typescript/src/errors/AuthorizationError.ts:18](https://github.com/pavancharak/AgentLabsBuildathon/blob/main/typescript/src/errors/AuthorizationError.ts#L18)

Raised when the Runtime returns HTTP 403 for a caller that is
authenticated but not permitted to do the specific thing it asked
for. Covers two distinct denials, both intentionally collapsed to
this one SDK error class since both share the same "who you are is
known; you can't do this" shape — distinguish them via `serverCode`/
`message` if needed, not via `instanceof`:

* a caller asserting an authority.principalId it isn't permitted to
  assert (isPrincipalAllowed, packages/api/src/routes/execute.ts and
  transactions.ts) — carries no `code` field of its own.
* a caller invoking a capability (intent.action) it isn't permitted
  to invoke (isCapabilityAllowed.ts) — carries
  `code: "CAPABILITY_NOT_ALLOWED"`, preserved on `serverCode` below.
  Distinct from AuthenticationError (401, no valid credential at all).

## Extends

* [`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError)

## Constructors

### Constructor

> **new AuthorizationError**(`message`, `options?`): `AuthorizationError`

Defined in: [typescript/src/errors/AuthorizationError.ts:27](https://github.com/pavancharak/AgentLabsBuildathon/blob/main/typescript/src/errors/AuthorizationError.ts#L27)

#### Parameters

##### message

`string`

##### options?

###### requestId?

`string`

###### cause?

`unknown`

###### serverCode?

`string`

#### Returns

`AuthorizationError`

#### Overrides

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`constructor`](/sdks/reference/typescript/classes/ParmanaError#constructor)

## Properties

### serverCode?

> `readonly` `optional` **serverCode?**: `string`

Defined in: [typescript/src/errors/AuthorizationError.ts:25](https://github.com/pavancharak/AgentLabsBuildathon/blob/main/typescript/src/errors/AuthorizationError.ts#L25)

The Runtime's own `code` field, when the 403 carried one (currently
only the capability-denied case: "CAPABILITY\_NOT\_ALLOWED"). Undefined
for the principal-mismatch case, which the Runtime sends with no
`code` at all — see mapHttpErrorResponse.ts for the exact check.

***

### code

> `readonly` **code**: [`ErrorCode`](/sdks/reference/typescript/enumerations/ErrorCode)

Defined in: [typescript/src/errors/ParmanaError.ts:61](https://github.com/pavancharak/AgentLabsBuildathon/blob/main/typescript/src/errors/ParmanaError.ts#L61)

Stable machine-readable error code.

#### Inherited from

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`code`](/sdks/reference/typescript/classes/ParmanaError#code)

***

### requestId?

> `readonly` `optional` **requestId?**: `string`

Defined in: [typescript/src/errors/ParmanaError.ts:66](https://github.com/pavancharak/AgentLabsBuildathon/blob/main/typescript/src/errors/ParmanaError.ts#L66)

Optional request identifier.

#### Inherited from

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`requestId`](/sdks/reference/typescript/classes/ParmanaError#requestid)

***

### cause?

> `readonly` `optional` **cause?**: `unknown`

Defined in: [typescript/src/errors/ParmanaError.ts:71](https://github.com/pavancharak/AgentLabsBuildathon/blob/main/typescript/src/errors/ParmanaError.ts#L71)

Optional underlying cause.

#### Inherited from

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`cause`](/sdks/reference/typescript/classes/ParmanaError#cause)

***

### stackTraceLimit

> `static` **stackTraceLimit**: `number`

Defined in: node\_modules/@types/node/globals.d.ts:68

The `Error.stackTraceLimit` property specifies the number of stack frames
collected by a stack trace (whether generated by `new Error().stack` or
`Error.captureStackTrace(obj)`).

The default value is `10` but may be set to any valid JavaScript number. Changes
will affect any stack trace captured *after* the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.

#### Inherited from

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`stackTraceLimit`](/sdks/reference/typescript/classes/ParmanaError#stacktracelimit)

***

### name

> **name**: `string`

Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1076

#### Inherited from

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`name`](/sdks/reference/typescript/classes/ParmanaError#name)

***

### message

> **message**: `string`

Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1077

#### Inherited from

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`message`](/sdks/reference/typescript/classes/ParmanaError#message)

***

### stack?

> `optional` **stack?**: `string`

Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1078

#### Inherited from

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`stack`](/sdks/reference/typescript/classes/ParmanaError#stack)

## Methods

### captureStackTrace()

> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`

Defined in: node\_modules/@types/node/globals.d.ts:52

Creates a `.stack` property on `targetObject`, which when accessed returns
a string representing the location in the code at which
`Error.captureStackTrace()` was called.

```js theme={null}
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`
```

The first line of the trace will be prefixed with
`${myObject.name}: ${myObject.message}`.

The optional `constructorOpt` argument accepts a function. If given, all frames
above `constructorOpt`, including `constructorOpt`, will be omitted from the
generated stack trace.

The `constructorOpt` argument is useful for hiding implementation
details of error generation from the user. For instance:

```js theme={null}
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
```

#### Parameters

##### targetObject

`object`

##### constructorOpt?

`Function`

#### Returns

`void`

#### Inherited from

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`captureStackTrace`](/sdks/reference/typescript/classes/ParmanaError#capturestacktrace)

***

### prepareStackTrace()

> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`

Defined in: node\_modules/@types/node/globals.d.ts:56

#### Parameters

##### err

`Error`

##### stackTraces

`CallSite`\[]

#### Returns

`any`

#### See

[https://v8.dev/docs/stack-trace-api#customizing-stack-traces](https://v8.dev/docs/stack-trace-api#customizing-stack-traces)

#### Inherited from

[`ParmanaError`](/sdks/reference/typescript/classes/ParmanaError).[`prepareStackTrace`](/sdks/reference/typescript/classes/ParmanaError#preparestacktrace)
