The prefix of the short link slug for randomly-generated keys (e.g. if prefix
is /c/, generated keys will be in the /c/:key format). Will be ignored if
key is provided.
The identifier of the short link that is unique across your workspace. If set,
it can be used to identify your short link for client-side click tracking.
An array of webhook IDs to trigger when the link is clicked. These webhooks will receive click event data.
Optionally, you can also pass an externalId field which is a unique identifier for the link in your own database to associate it with the link in Dub’s system.
index.rb
post "/links"do req =::OpenApiSDK::Operations::CreateLinkRequest.new( request_body:::OpenApiSDK::Operations::CreateLinkRequestBody.new( url:'https://google.com', external_id:'12345')) res = dub.links.create(req) content_type :json res.raw_response.bodyend
Dub Ruby SDK provides a method to upsert a link – where an existing link is updated if it exists, or a new link is created if it doesn’t. so you don’t have to worry about checking if the link already exists.
index.rb
put "/links"do req =::OpenApiSDK::Operations::UpsertLinkRequest.new( request_body:::OpenApiSDK::Operations::UpsertLinkRequestBody.new( url:"https://google.com",),) res = dub.links.upsert(req) content_type :json res.raw_response.bodyend
This way, you won’t have to worry about checking if the link already exists when you’re creating it.