What is the new `external_id` feature for topics used for?

From https://meta.discourse.org/t/2-9-0-beta2-security-fix-and-more/218086:

Add support for external_id to be used when creating and fetching topics. This is an API-only change

I have several (experimental at this point) api-based bots which link topics to external resources (like related bug or issue trackers relating to a conversion). https://docs.discourse.org tells me what this is but not a lot of details of how this is meant to be used. Is there a longer explanation? It seems like this could be really useful!

3 Likes

What drove this feature is that a lot of sites need to interact with discourse via some other external application but they often don’t have a good way of keeping track of all the internal discourse id’s for things to keep things in sync. Now that you can create a topic with an external_id it can become a lot easier to match up a specific discourse topic with a resource in your own application.

Just to clarify this new external_id feature is only for topics, not posts. So a topic can store an external_id, but a post cannot.

3 Likes

Thanks @blake. So, “external_id” can be arbitrary from my side? For Common Issues - Ask Fedora, I’ve been doing something fairly horrible — getting the top post and then scanning the link_counts list for URLs which match the pattern of the external resource.

Yes, as long as it falls under the format of a 50 character string including - and _.

2 Likes

Ah, good to know. So, bug numbers, not full URLs. :slight_smile:

1 Like

Hi @blake,
We’re happily using the external_id feature for our integration. I note however that if we delete a Topic, we can not create a new one with the same external_id and instead receive the error:

{'action': 'create_post', 'errors': ['External has already been taken']}

Is it at all possible to re-use the same external_id after a Topic that used it is deleted?

3 Likes