> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/developers/gitbook-api/api-reference/spaces/space-embeds.md).

# Space embeds

Automatically fetch metadata or previews for embedded resources such as videos, images, or external docs, enabling richer content experiences in your space.

## Resolve a URL to an oEmbed object within a space

> Resolves an external URL to an oEmbed representation (title, thumbnail, HTML snippet) within the context of a space. Use this to preview or embed third-party content referenced in a space's pages. Requires the URL as a query parameter.

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"space-embeds","description":"Automatically fetch metadata or previews for embedded resources such as videos, images, or external docs, enabling richer content experiences in your space.\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]},{"oauth":["space:read"]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"},"oauth":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://oauth.gitbook.com/authorize","tokenUrl":"https://oauth.gitbook.com/token","scopes":{"user:read":"Read your GitBook user profile.","organization:read":"Read organization settings and metadata.","organization:write":"Create and update organization settings.","organization:members:read":"Read organization members, invites and link invites.","organization:members:write":"Manage organization members, invites and link invites.","organization:ask":"Ask AI questions across an organization's content.","organization:search":"Search across an organization's content.","space:read":"Read spaces and their content.","space:write":"Create, update and delete spaces and their content, including imports.","space:permissions:read":"Read space permissions.","space:permissions:write":"Manage space permissions.","change-request:merge":"Merge change requests, publishing their changes to the space.","site:read":"Read sites and their settings.","site:write":"Create, update and delete sites, sections and their settings.","site:publish":"Publish and unpublish sites, controlling their public exposure.","site:permissions:read":"Read site permissions.","site:permissions:write":"Manage site permissions.","site:auth:read":"Read site authentication and security configuration.","site:auth:write":"Manage site authentication and security configuration.","site:insights:read":"Read site analytics and insights.","site:ask":"Ask AI questions across a site's content.","site:search":"Search across a site's content.","openapi:read":"Read OpenAPI specifications.","openapi:write":"Create, update and delete OpenAPI specifications."}}}}},"parameters":{"spaceId":{"name":"spaceId","in":"path","required":true,"description":"The unique id of the space","schema":{"$ref":"#/components/schemas/EntityId"}}},"schemas":{"EntityId":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"A unique entity identifier"},"Embed":{"allOf":[{"type":"object","properties":{"title":{"type":"string"},"site":{"type":"string"},"icon":{"type":"string"}},"required":["title","site"]},{"oneOf":[{"type":"object","title":"Link","properties":{"type":{"type":"string","enum":["link"]}},"required":["type"]},{"type":"object","title":"HTML","properties":{"type":{"type":"string","enum":["rich"]},"html":{"type":"string"}},"required":["type","html"]},{"type":"object","title":"Integration","properties":{"type":{"type":"string","enum":["integration"]},"integration":{"description":"The identifier of the integration performing the rendering","type":"string"},"block":{"$ref":"#/components/schemas/IntegrationBlock"}},"required":["type","integration","block"]}]}]},"IntegrationBlock":{"type":"object","properties":{"id":{"type":"string","description":"Unique ID in the integration for the block. It also represents the UI component used."},"title":{"type":"string","description":"Short descriptive title for the block.","minLength":2,"maxLength":40},"description":{"type":"string","description":"Long descriptive text for the block.","minLength":0,"maxLength":150},"icon":{"type":"string","description":"URL of the icon to represent this block."},"urlUnfurl":{"type":"array","description":"URLs patterns to convert as this block.","items":{"type":"string"}},"markdown":{"$ref":"#/components/schemas/IntegrationBlockMarkdown"}},"required":["id","title"]},"IntegrationBlockMarkdown":{"oneOf":[{"type":"object","description":"Format the custom block as a codeblock","properties":{"codeblock":{"description":"Code block syntax to use to identify the block.","type":"string"},"body":{"description":"Key of the property to use as body of the codeblock.","type":"string"}},"required":["codeblock","body"]}]}}},"paths":{"/spaces/{spaceId}/embed":{"get":{"operationId":"getEmbedByUrlInSpace","summary":"Resolve a URL to an oEmbed object within a space","description":"Resolves an external URL to an oEmbed representation (title, thumbnail, HTML snippet) within the context of a space. Use this to preview or embed third-party content referenced in a space's pages. Requires the URL as a query parameter.","tags":["space-embeds"],"parameters":[{"$ref":"#/components/parameters/spaceId"},{"name":"url","in":"query","required":true,"description":"URL to resolve","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Embed"}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gitbook.com/docs/developers/gitbook-api/api-reference/spaces/space-embeds.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
