An approach using listofitems. A concatenated list of arguments to the macro is created, and then searched for duplication. I provide verbose output (which can be removed) to show how it works.
\documentclass{article}
\usepackage{listofitems}
\def\usedIds{}
\makeatletter
\newcommand\uniqueId[1]{%
\g@addto@macro\usedIds{#1\endlinechar}%
\setsepchar{#1\endlinechar}%
\readlist\IDlist{\usedIds}%
\ifnum\listlen\IDlist[]>2\relax%
\typeout{BOOM! #1 is a duplicate.}BOOM! #1 is a duplicate.
\else
#1 OK.
\fi%
}
\makeatother
\begin{document}
\uniqueId{foo}
\uniqueId{foobar}
\uniqueId{foo}
\uniqueId{foobar}
\uniqueId{foobar}
\end{document}

Here is a non-verbose version that types out to the console and then triggers an error.
\documentclass{article}
\usepackage{listofitems}
\def\usedIds{}
\makeatletter
\newcommand\uniqueId[1]{%
\g@addto@macro\usedIds{#1\endlinechar}%
\setsepchar{#1\endlinechar}%
\readlist\IDlist{\usedIds}%
\ifnum\listlen\IDlist[]>2\relax%
\typeout{BOOM! #1 is a duplicate.}
Abort \uniqueIdHasBeenTriggered
\fi%
}
\makeatother
\begin{document}
\uniqueId{foo}
\uniqueId{foobar}
\uniqueId{foo}
\uniqueId{foobar}
\uniqueId{foobar}
\end{document}
The console is this:
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6350)
entering extended mode
(C:/steven.segletes/TeX/Working/junk.tex
LaTeX2e <2017-04-15>
Babel <3.10> and hyphenation patterns for 72 language(s) loaded.
(C:\MikTeX\tex\latex\base\article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(C:\MikTeX\tex\latex\base\size10.clo))
(C:\MikTeX\tex\latex\listofitems\listofitems.sty
(C:\MikTeX\tex\generic\listofitems\listofitems.tex)) (junk.aux)
BOOM! foo is a duplicate.
! Undefined control sequence.
\uniqueId ...te.} Abort \uniqueIdHasBeenTriggered
\fi
l.20 \uniqueId{foo}
?
Process interrupted by user
\seq_if_in:NnTFdoes not just look like... assembly language or some esoteric language from the 70s... Anyway: THANKS! – Colas Apr 18 '18 at 19:37\seq_if_inis too esoteric for you, my solution was not really useful to you. Deleted it... – Apr 18 '18 at 19:55