Skip to content

Add docs for api/fabric/embeds/token endpoint#120

Merged
Devon-White merged 12 commits intomainfrom
diego/13703/document-fabric-embed-token
Apr 4, 2025
Merged

Add docs for api/fabric/embeds/token endpoint#120
Devon-White merged 12 commits intomainfrom
diego/13703/document-fabric-embed-token

Conversation

@diego-signalwire
Copy link
Contributor

@diego-signalwire diego-signalwire commented Mar 16, 2025

REST API Update Pull Request

Related Issue

Issue #13703

Description

Click to Call allows users to embed widgets in their website that let them utilize fabric resources for calling.
To use it, a developer will send a request from a browser or sever with the ApiKey (generated via the UI). If the request is allowed by the settings (assigned address), then we will return a valid SAT token.

Type of Change

  • New endpoint
  • Update to existing endpoint

Motivation and Context

We don't have this endpoint documented, and we should. The namespace is api/fabric/embeds/tokens, and it is separate from the existing Guest/Invite tokens for subscribers.

The endpoint is public (allows requests without authorization)
The endpoint returns 403 Forbidden if the ApiKey setting is invalid
The endpoint returns a valid SAT if the ApiKey setting is valid

Checklist:

  • I have read and fully understand the process for updating the REST API
  • Mandatory fields are present in the TypeSpec files.
  • TypeSpec files successfully compiled OpenAPI spec files.
    • No new warnings were generated during the compilation process.
  • OpenAPI spec files were validated with a SWAGGER UI tool to ensure they are correct.
  • The DevEx team has been alerted with the new changed by including the team/developer-experience label in the PR.

Additional Notes

Screenshot 2025-03-17 at 11 03 40

@netlify
Copy link

netlify bot commented Mar 16, 2025

Deploy Preview for signalwire-docs ready!

Name Link
🔨 Latest commit f98a15a
🔍 Latest deploy log https://app.netlify.com/sites/signalwire-docs/deploys/67f01fd55f277f0008309585
😎 Deploy Preview https://deploy-preview-120--signalwire-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

meyerisabela
meyerisabela previously approved these changes Mar 17, 2025
Copy link
Contributor

@meyerisabela meyerisabela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@Devon-White
Copy link
Contributor

@diego-signalwire Since this is the fabric endpoint, and not all endpoints have been copnverted to TypeSpec, we will need to take the generated spec for this endpoint and migrate it over to the _spec_.yaml file in the fabric directory.

Once all fabric endpoints are converted to TypeSpec, we wont have to worry about this issue anymore.

@Devon-White
Copy link
Contributor

Devon-White commented Mar 21, 2025

@diego-signalwire If the endpoint is not meant to have any auth, we can actually hardset this in TypeSpec utilizing the @useAuth like so:

// Define the API path for embeds
@useAuth({ type: Http.AuthType.noAuth })
@route("/embeds/tokens")
namespace FabricAPI.EmbedsTokens {
    @tag("Embeds Tokens")
    @friendlyName("Embeds Tokens")
    interface EmbedsTokens {
        @summary("Create Embeds Tokens")
        @post
        create(@body body: EmbedsTokensRequest):
        { @statusCode statusCode: 201; @body subscriber: EmbedsTokensResponse; } |
        StatusCode401 |
        StatusCode404 |
        StatusCode403;
    }
}

I went ahead and pushed this change.

Additionally, the space name doesn't seem to matter in the request url? I was able to provide my c2c token in my space with the random space name of YOUR_SPACE. If the space name isnt checked/validated does it make sense to remove the space_name variable and just make this a static request url, so a space name isnt needed?

Can I also get clarification on what the endpoint does? It seems to me you provide it a generated c2c token, and can create a embed guest token out of this? I'm not sure i understand the benefit of this, i was already assuming the token created for c2c was already restricted?

@diego-signalwire
Copy link
Contributor Author

diego-signalwire commented Mar 26, 2025

@diego-signalwire If the endpoint is not meant to have any auth, we can actually hardset this in TypeSpec utilizing the @useAuth like so:

// Define the API path for embeds
@useAuth({ type: Http.AuthType.noAuth })
@route("/embeds/tokens")
namespace FabricAPI.EmbedsTokens {
    @tag("Embeds Tokens")
    @friendlyName("Embeds Tokens")
    interface EmbedsTokens {
        @summary("Create Embeds Tokens")
        @post
        create(@body body: EmbedsTokensRequest):
        { @statusCode statusCode: 201; @body subscriber: EmbedsTokensResponse; } |
        StatusCode401 |
        StatusCode404 |
        StatusCode403;
    }
}

I went ahead and pushed this change.

Additionally, the space name doesn't seem to matter in the request url? I was able to provide my c2c token in my space with the random space name of YOUR_SPACE. If the space name isnt checked/validated does it make sense to remove the space_name variable and just make this a static request url, so a space name isnt needed?

The team thinks that we should not validate the space name and we are using a static request URL on provider callback, usually stack1 and the team is not 100% sure if we want that in the docs. Could you keep this way?

Can I also get clarification on what the endpoint does? It seems to me you provide it a generated c2c token, and can create a embed guest token out of this? I'm not sure i understand the benefit of this, i was already assuming the token created for c2c was already restricted?

I asked about the purpose of this endpoint on the eng-prime-team and this is what I understood about Bryan's response:

The C2C (Click-to-Call) token is a public, long-lived identifier that represents a specific C2C configuration. However, it does not provide access on its own — it’s meant to identify which C2C widget you intend to activate.

This endpoint exists to exchange the C2C token for a short-lived, private embed guest token that actually authorizes the call. This adds a layer of security: if the public token is compromised or abused, it can be rotated without affecting access control. This approach separates identification (C2C token) from authorization (guest token), which is a common security practice.

Let me know if does make sense to you.

@Devon-White
Copy link
Contributor

@diego-signalwire This does make sense thank you for explaining this! :)

Additionally i made the following TypeSpec discussion: microsoft/typespec#6696

Once we get a answer from them, ill know how to go about the URL for this spec.

@Devon-White
Copy link
Contributor

Regarding the above issue with TypeSpec. It seems the issue has been placed in backlog. Once I'm done with my current priorities, I will look into the best way to handle this.

@github-actions
Copy link

github-actions bot commented Apr 4, 2025

OpenAPI Specification Analysis

Changes are compared to the main branch:

  • 🟢 Improvements (higher scores or fewer issues)
  • 🔴 Regressions (lower scores or more issues)
  • ⚪ No changes
Spec Docs Completeness SDK Gen Security Overall Warnings Errors Report
api/compatibility-api/_spec_.yaml 72/100
(=) ⚪
69/100
(=) ⚪
79/100
(=) ⚪
39/100
(=) ⚪
65/100
(=) ⚪
448
(=) ⚪
360
(=) ⚪
View
api/signalwire-rest/calling-api/tsp-output/@typespec/openapi3/openapi.yaml 98/100
(=) ⚪
95/100
(=) ⚪
97/100
(=) ⚪
50/100
(=) ⚪
85/100
(=) ⚪
20
(=) ⚪
6
(=) ⚪
View
api/signalwire-rest/chat-api/tsp-output/@typespec/openapi3/openapi.yaml 98/100
(=) ⚪
95/100
(=) ⚪
97/100
(=) ⚪
50/100
(=) ⚪
85/100
(=) ⚪
12
(=) ⚪
4
(=) ⚪
View
api/signalwire-rest/datasphere-api/tsp-output/@typespec/openapi3/openapi.yaml 97/100
(=) ⚪
94/100
(=) ⚪
96/100
(=) ⚪
51/100
(=) ⚪
85/100
(=) ⚪
65
(=) ⚪
18
(=) ⚪
View
api/signalwire-rest/fabric-api/_spec_.yaml 74/100
(=) ⚪
71/100
(=) ⚪
91/100
(=) ⚪
44/100
(=) ⚪
70/100
(=) ⚪
691
(+8) 🔴
382
(+2) 🔴
View
api/signalwire-rest/fax-api/_spec_.yaml 38/100
(=) ⚪
35/100
(=) ⚪
86/100
(=) ⚪
39/100
(=) ⚪
50/100
(=) ⚪
18
(=) ⚪
15
(=) ⚪
View
api/signalwire-rest/message-api/_spec_.yaml 53/100
(=) ⚪
50/100
(=) ⚪
86/100
(=) ⚪
38/100
(=) ⚪
57/100
(=) ⚪
18
(=) ⚪
11
(=) ⚪
View
api/signalwire-rest/project-api/_spec_.yaml 76/100
(=) ⚪
73/100
(=) ⚪
69/100
(=) ⚪
36/100
(=) ⚪
64/100
(=) ⚪
21
(=) ⚪
14
(=) ⚪
View
api/signalwire-rest/pubsub-api/_spec_.yaml 98/100
(=) ⚪
95/100
(=) ⚪
88/100
(=) ⚪
36/100
(=) ⚪
80/100
(=) ⚪
11
(=) ⚪
6
(=) ⚪
View
api/signalwire-rest/space-api/_spec_.yaml 73/100
(=) ⚪
70/100
(=) ⚪
87/100
(=) ⚪
40/100
(=) ⚪
68/100
(=) ⚪
323
(=) ⚪
233
(=) ⚪
View
api/signalwire-rest/video-api/_spec_.yaml 86/100
(=) ⚪
85/100
(=) ⚪
86/100
(=) ⚪
39/100
(=) ⚪
74/100
(=) ⚪
179
(=) ⚪
131
(=) ⚪
View
api/signalwire-rest/voice-api/_spec_.yaml 53/100
(=) ⚪
50/100
(=) ⚪
86/100
(=) ⚪
38/100
(=) ⚪
57/100
(=) ⚪
18
(=) ⚪
11
(=) ⚪
View

@Devon-White Devon-White merged commit a7c10b0 into main Apr 4, 2025
6 checks passed
@Devon-White Devon-White deleted the diego/13703/document-fabric-embed-token branch April 4, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants