---
title: "Specs hooks"
description: "Hand-written shim. Generated CRUD hooks via ./specs.gen.
The refresh custom-op hook stays hand-written until the React gen
learns to emit kind: \"custom\" ops. Spec members are their own
generated top-level entity (`useListSpecMembers` from spec-members.gen)."
section: "Libraries"
group: "React hooks"
order: 450
---

## Hooks

### `useCreateSpec` `mutation`

Create a spec. Fetches the OpenAPI spec from sourceUrl and generates functions + schemas for every operation.

```ts
useCreateSpec(options?: MutationOpts<Spec, CreateSpecParams>)
```

**Types:** [Spec](/types/spec) · [CreateSpecParams](/types/create-spec-params)

### `useDeleteSpec` `mutation`

Soft-delete a spec. Generated entities cascade-remove via spec_member; the wrapping solution is preserved (unwraps).

```ts
useDeleteSpec(options?: MutationOpts<SuccessResponse, string>)
```

**Types:** [SuccessResponse](/types/success-response)

### `useListSpecs` `query`

List specs.

```ts
useListSpecs(params?: Omit<ListSpecsParams, | > & { filter?: SpecFilter; orderBy?: SpecOrderBy[]; } & SpecShorthands, options?: QueryOpts<Page<Spec>>)
```

**Types:** [ListSpecsParams](/types/list-specs-params) · [SpecFilter](/types/spec-filter) · [SpecOrderBy](/types/spec-order-by) · [SpecShorthands](/types/spec-shorthands) · [Page](/types/page) · [Spec](/types/spec)

### `usePurgeSpec` `composite`

Permanently delete a soft-deleted spec.

```ts
usePurgeSpec(options?: MutationOpts<SuccessResponse, PurgeSpecParams>)
```

**Types:** [SuccessResponse](/types/success-response) · [PurgeSpecParams](/types/purge-spec-params)

### `useRefreshSpec` `composite`

```ts
useRefreshSpec(options?: MutationOpts<RefreshSpecResponse, RefreshSpecParams>)
```

**Types:** [RefreshSpecResponse](/types/refresh-spec-response) · [RefreshSpecParams](/types/refresh-spec-params)

### `useRestoreSpec` `composite`

Restore a soft-deleted spec.

```ts
useRestoreSpec(options?: MutationOpts<Spec, string>)
```

**Types:** [Spec](/types/spec)

### `useRetrieveSpec` `query`

Get a spec by ID.

```ts
useRetrieveSpec(id: string, options?: QueryOpts<Spec>)
```

**Types:** [Spec](/types/spec)

### `useUpdateSpec` `mutation`

Update a spec's metadata or auth config. Does NOT refetch the spec — call refresh explicitly.

```ts
useUpdateSpec(options?: MutationOpts<Spec, UpdateSpecParams>)
```

**Types:** [Spec](/types/spec) · [UpdateSpecParams](/types/update-spec-params)
