This is essentially found in the Fundamental Lemma of Sieve Theory, which is a deep and interesting result. As its name suggests, it is quite important in the area of sieve theory. Granville and Soundarajan have some good notes on this, which you can find here. Their Theorem 1.4.2 (which can be found on page 37 of the notes I linked) is as follows. I've changed their notation to reflect the notation in your question.
Theorem (The Fundamental Lemma of Sieve Theory). Let $q$ be an integer with $(q,l)=1$, such that every prime factor of $q$ is $\leq (B/l)^{1/u}$ for some given $u = \frac{\log A}{\log B}\geq 1$. Then, uniformly [in the variables $A,B,q,l,a$], we have
$$
\sum_{\substack{A \leq n \leq A+B\\ (n,q)=1 \\n\equiv a\ (\text{mod}\ l)}} 1 = \frac{B}{l} \frac{\phi(q)}{q}\left(1 + O(u^{-u/2}) \right) + O\left(\left(\frac{B}{l}\right)^{3/4+o(1)}\right).
$$
Taking $a=l=1$, we get that
$$
\sum_{\substack{A \leq n \leq A+B\\ (n,q)=1 }} 1 = \frac{B\phi(q)}{q}\left(1 + O(u^{-u/2}) \right) + O\left(B^{3/4+o(1)}\right).
$$
The proof of the Fundamental Lemma is a bit too long to be written here. Whether or not this estimate constitutes and asymptotic or just and upper bound depends on how $B$ and $q$ grow with $A$.
It should be noted that the error term you have written is certainly false. In general, you should always expect your error term to depend on the length of your sum in some way. Except in very specific cases (such as the Polya-Vonogradov inequality), this is universally true of problems in analytic number theory.